How can I run hierarchical clustering on a correlation matrix in scipy/numpy? I have a matrix of 100 rows by 9 columns, and I\'d like to hierarchicall
scipy
numpy
Just change the metric to correlation so that the first line becomes:
correlation
Y=pdist(X, 'correlation')
However, I believe that the code can be simplified to just:
Z=linkage(X, 'single', 'correlation') dendrogram(Z, color_threshold=0)
because linkage will take care of the pdist for you.