Skip to content

Instantly share code, notes, and snippets.

@interrogator
Last active June 7, 2016 12:05
Show Gist options
  • Save interrogator/ac7f3445011bbf06270e355797cce860 to your computer and use it in GitHub Desktop.
Save interrogator/ac7f3445011bbf06270e355797cce860 to your computer and use it in GitHub Desktop.
dendogramming
%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