hierarchical clustering on correlations in Python scipy/numpy? hierarchical clustering on correlations in Python scipy/numpy? numpy numpy

hierarchical clustering on correlations in Python scipy/numpy?


Just change the metric to correlation so that the first line becomes:

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.