Pruning dendrogram in scipy (hierarchical clustering)

前端 未结 1 1719
执念已碎
执念已碎 2021-02-13 16:41

I have a distance matrix with about 5000 entries, and use scipy\'s hierarchical clustering methods to cluster the matrix. The code I use for this is the following snippet:

1条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-13 17:06

    One of the dictionary data-structures returned by scipy.cluster.hierarchy.dendrogram has the key ivl, that the documentation describes as:

    a list of labels corresponding to the leaf nodes

    You can supply custom labels (using labels=) as input to the dendrogram function but by default, they are just indices of the original observation. By comparing the original labels/indices and Z1['ivl'], you can determine what the original entries were.

    0 讨论(0)
提交回复
热议问题