In python, I have an N by N distance matrix dmat, where dmat[i,j] encodes the distance from entity i to entity j. I'd like to view a dendrogram. I did:
from scipy.cluster.hierarchy import dendrogram, linkage
import matplotlib.pylab as plt
labels=[name of entity 1,2,3,...]
Z=linkage(dmat)
dn=dendrogram(Z,labels=labels)
plt.show()
But the label ordering looks wrong. There are entities which are very close from dmat, but that's not reflected in the dendrogram. What's going on?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…