sklearn中的聚集聚类 [英] agglomerative clustering in sklearn
本文介绍了sklearn中的聚集聚类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
我们将距离矩阵称为D
.
agg = AgglomerativeClustering(n_clusters=5, affinity='precomputed', linkage = 'average')
agg.fit_predict(D) # Returns class labels.
如果您有兴趣生成整个层次结构并生成树状图,则scikit-learn
的API会包装 解决方案
Let's call your distance matrix D
.
agg = AgglomerativeClustering(n_clusters=5, affinity='precomputed', linkage = 'average')
agg.fit_predict(D) # Returns class labels.
If you're interested in generating the entire hierarchy and producing a dendrogram, scikit-learn
's API wraps the scipy
hierarchical clustering code. Just use the scipy
code directly.
这篇关于sklearn中的聚集聚类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文