【发布时间】:2013-01-16 00:03:45
【问题描述】:
我有一个距离矩阵表示成对元素的距离矩阵 比如
A B C D .....
A n1 n2 n3
B n1
C n2 n4
D n3 n5 .......
E.........
我输入数组,比如聚类
arry= [ 0 n1, n2, n3..
n1.......
n2 n4
n3 n5 ]
Y=sch.linkage(arry,'single')
cutoff=1e-6
T=sch.fcluster(Y, cutoff,'distance')
print T
Z=sch.dendrogram(Y, color_threshold=cutoff)
我的 fcluster 输出就像 [ 4 10 12 1 5 13 2 11 1 7 8 3 14 6 10 16 9 15 1 7] 来自其他人以前的海报 Clustering with scipy - clusters via distance matrix, how to get back the original objects
我明白了 输出 T[i] 仅显示集群中元素的数量..我如何将原始元素 A、B、C、D、E..... 元素与集群结果和树状图联系起来?并将它们正确地添加到我的数字中。
【问题讨论】:
-
说真的,请阅读 scipy 文档。 docs.scipy.org/doc/scipy/reference/generated/…
标签: python numpy scipy cluster-analysis hierarchical-clustering