似乎确实不能直接传递冗余方阵,尽管文档声称可以这样做。
为了使将来遇到相同问题的任何人受益,我在此处写我的解决方案作为附加答案。因此,复制粘贴人员可以继续进行聚类。
使用以下代码段压缩矩阵并愉快地进行。
import scipy.spatial.distance as ssd# convert the redundant n*n square matrix form into a condensed nC2 array distArray = ssd.squareform(distMatrix) # distArray[{n choose 2}-{n-i choose 2} + (j-i-1)] is the distance between points i and j如果我错了,请纠正我。



