Using the code posted here, I created a nice hierarchical clustering:
Let's say the the dendrogram on the left was created by doing something like
Y = sch.linkage(D, method='average') # D is a distance matrix
cutoff = 0.5*max(Y[:,2])
Z = sch.dendrogram(Y, orientation='right', color_threshold=cutoff)
Now how do I get the indices of the members of each of the colored clusters? To simplify this situation, ignore the clustering on the top, and focus only on the dendrogram on the left of the matrix.
This information should be stored in the dendrogram Z
stored variable. There is a function that should do just what I want called fcluster
(see documentation here). However I cannot see where I can give fcluster the same cutoff
as I specified in the creation of the dendrogram. It seems that the threshold variable in fcluster
, t
has to be in terms of various obscure measurements (inconsistent
, distance
, maxclust
, monocrit
). Any ideas?
D
is a symmetric distance matrix, then you are wrong. Instead, the input oflinkage()
should be a n-choose-2 array as @Steve has done. – Alt