【发布时间】:2020-02-28 23:25:11
【问题描述】:
我有一个使用 k-means 算法的文本聚类项目。我的数据集是 Facebook cmets 的政治情绪,因此每条评论都有正面、负面和中立的标签。
我在我的应用程序中做了如下:
1. Normalize text and delete stopwords.
2. Term weighting using tf-idf.
3. Constructing a matrix of vectors for each comment data.
4. Set the number of clusters to 3 (based on the number of labels).
5. Choose centroid randomly based on the label. So each label contributes 1 comment as a centroid.
6. Calculate the distance of each comment's vector with each centroid, assign to the closest centroid.
7. Calculate the vector's average of each cluster as a new centroid.
8. Repeat steps 6 and 7 until the centroid does not change.
9. The final cluster results.
在我得到的聚类结果中,有些聚类没有成员。比如我将集群的数量设置为 3,但结果是只有 2 个集群有成员,另外 1 个集群是空的。
这对 k-means 算法可行吗?如何解决这个问题?或者我的应用程序中可能有错误?
【问题讨论】: