hierarchical clustering on correlations in Python scipy/numpy?
Posted
by user248237
on Stack Overflow
See other posts from Stack Overflow
or by user248237
Published on 2010-05-25T19:39:00Z
Indexed on
2010/05/25
19:41 UTC
Read the original article
Hit count: 357
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 hierarchically clustering by correlations of each entry across the 9 conditions. I'd like to use 1-pearson correlation as the distances for clustering. Assuming I have a numpy array "X" that contains the 100 x 9 matrix, how can I do this?
I tried using hcluster, based on this example:
Y=pdist(X, 'seuclidean')
Z=linkage(Y, 'single')
dendrogram(Z, color_threshold=0)
however, pdist is not what I want since that's euclidean distance. Any ideas?
thanks.
© Stack Overflow or respective owner