1

I'm using agglomerative hierarchical clustering for news headlines clustering. But instead of having a flat cut through dendrogram for generating cluster, I want to use some other ways.

from scipy.cluster.hierarchy import fcluster, linkage, dendrogram
Z = linkage(np.array(distance_matrix), "average")
Z
array([[ 4235.,  4296.,     0.,     2.],
       [ 2867.,  3004.,     0.,     2.],
       [ 3220.,  3368.,     0.,     2.],
       ...,
       [ 6227., 14207.,     1.,    12.],
       [12355., 14208.,     1.,    14.],
       [14197., 14209.,     1.,  7106.]])

At every any step(i) cluster Z[i,0] merges with cluster Z[i,1] and a new cluster is created as C. where C = n+i

n = total number of points

i = step(every merge is a step first merge is step 0)

how to get the original member(point in the cluster) of the cluster C?Is there a scipy function for this.

mad_boy
  • 371
  • 4
  • 13
  • Possible duplicate of [How to compute cluster assignments from linkage/distance matrices in scipy in Python?](https://stackoverflow.com/questions/15951711/how-to-compute-cluster-assignments-from-linkage-distance-matrices-in-scipy-in-py) – anilbey Mar 06 '19 at 09:19
  • I think this was answered here: https://stackoverflow.com/questions/65034792/print-all-clusters-and-samples-at-each-step-of-hierarchical-clustering-in-python – SFW Jul 01 '22 at 23:24

0 Answers0