Last active
June 7, 2016 12:05
-
-
Save interrogator/ac7f3445011bbf06270e355797cce860 to your computer and use it in GitHub Desktop.
dendogramming
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%matplotlib notebook | |
import seaborn as sns | |
import numpy as np | |
from scipy.spatial.distance import pdist | |
from scipy.cluster.hierarchy import linkage, dendrogram | |
# pdist can be 'braycurtis', 'canberra', 'chebyshev', 'cityblock', 'correlation', 'cosine', | |
# 'dice', 'euclidean', 'hamming', 'jaccard', 'kulsinski', 'mahalanobis', 'matching', | |
#'minkowski', 'rogerstanimoto', 'russellrao', 'seuclidean', 'sokalmichener', 'sokalsneath', 'sqeuclidean', 'yule' | |
#linkage can be 'single', 'complete', 'average', 'weighted' | |
df = ???? | |
X = df.T.values | |
Y = pdist(X, 'hamming') | |
Z = linkage(Y, 'single') | |
dendrogram(Z, labels=df.columns, orientation='right') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment