我正在尝试创建使用分层凝聚聚类对文档进行聚类的程序,并且该程序的输出取决于将树状图切割到我获得最大纯度的级别。
所以以下是我现在正在研究的算法。
Create dedrogram for the documents in the dataset
purity = 0
final_clusters
for all the levels, lvl, in the dendrogram
clusters = cut dendrogram at lvl
new_purity = calculate_purity_of(clusters)
if new_purity > purity
purity = new_purity
final_clusters = clusters
根据这个算法,我得到了在所有级别上计算出的纯度最高的簇。
问题是,当我在最低级别切割树状图时,每个簇只包含一个文档,这意味着它是 100% 纯的,因此簇的平均纯度为 1.0。但这不是所需的输出。我想要的是对文件进行适当的分组。难道我做错了什么?