知识卡片
质心差可作简单分类方向
分别求两类训练向量的均值得到质心,正类减负类形成方向;新向量与它点积可作分类分数。它只用类均值差异,是教学近似;完整线性判别分析还考虑共享类内协方差及先验,不普遍等于直接连质心。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
- · 从词数到语义分析
原书出处 · 1 处
- · 查看原书依据
Let’s manually perform this approximation of LDA and see how it does on our dataset: >>> mask = comments.toxic.astype(bool).values #1 >>> toxic_centroid = tfidf_docs[mask].mean(axis=0) #2 >>> nontoxic_centroid = tfidf_docs[~mask].mean(axis=0) #3 >>> centroid_axis = toxic_centroid - nontoxic_centroid >>> toxicity_score = tfidf_docs.dot(centroid_axis) #4 >>> toxicity_score.round(3) array([-0.008, -0.022, -0.014, ..., -0.025, -0.001, -0.022]) #1 You can use this mask to select only the toxic comment rows from a
参考来源
- 位置:《Natural Language Processing in Action, Second Edition》第04章《从词数到语义分析》(来源项目:a19c7933-4eda-4176-aebd-30fe7e1ad292;源文件:extracted/Natural Language Processing in Action, Second Edition/_epub-src/OEBPS/Text/chapter-4.html)
- 结论依据:摘录中关于质心差可作简单分类方向的定义、比较或条件支撑卡片;原书表述不严谨的范围已在覆盖记录逐项限定,不把案例结果外推为普遍结论。
- 原始内容:Let’s manually perform this approximation of LDA and see how it does on our dataset: >>> mask = comments.toxic.astype(bool).values #1 >>> toxic_centroid = tfidf_docs[mask].mean(axis=0) #2 >>> nontoxic_centroid = tfidf_docs[~mask].mean(axis=0) #3 >>> centroid_axis = toxic_centroid - nontoxic_centroid >>> toxicity_score = tfidf_docs.dot(centroid_axis) #4 >>> toxicity_score.round(3) array([-0.008, -0.022, -0.014, ..., -0.025, -0.001, -0.022]) #1 You can use this mask to select only the toxic comment rows from a