【发布时间】:2021-04-04 06:02:35
【问题描述】:
我有一个文本语料库,其中包含 1000 多篇文章,每篇文章单独一行。我正在尝试在 python 中使用 Hierarchy Clustering using Scipy 来生成相关文章的集群。 这是我用来做聚类的代码
# Agglomerative Clustering
import matplotlib.pyplot as plt
import scipy.cluster.hierarchy as hac
tree = hac.linkage(X.toarray(), method="complete",metric="euclidean")
plt.clf()
hac.dendrogram(tree)
plt.show()
我得到了这个情节
然后我用 fcluster() 在第三层砍掉树
from scipy.cluster.hierarchy import fcluster
clustering = fcluster(tree,3,'maxclust')
print(clustering)
我得到了这个输出: [2 2 2 ..., 2 2 2]
我的问题是如何找到每个集群中的前 10 个常用词,以便为每个集群建议一个主题?
【问题讨论】:
-
为什么你认为 3 是一个合适的值?
标签: python scipy cluster-analysis text-mining