0

I am doing a hierarchical agglomerative clustering. Everything is working fine, but I want to do representation of t vs. number of cluster of the dendrogram.

The only info about the dendrogram is the Z matix in the following code, but I don't know what the clust matrix mean.

import seaborn as sns
import scipy.cluster.hierarchy as sch
from scipy.cluster.hierarchy import dendrogram, linkage, fcluster
iris = sns.load_dataset("iris")
species = iris.pop("species")
Z = linkage(X, 'ward')
fig = plt.figure(figsize=(25, 10))
dn = dendrogram(Z)

So for this case I would have (number of cluster,t) the values of (2,30) , (3,10) and so on, but the closer we get to t=0 the harder it is to count all

  • `NameError: name 'X' is not defined` – Trenton McKinney Feb 03 '23 at 15:34
  • Maybe https://stackoverflow.com/questions/9838861/scipy-linkage-format and https://stackoverflow.com/questions/37712465/what-is-the-meaning-of-the-return-values-of-the-scipy-cluster-hierarchy-linkage help? – JohanC Feb 03 '23 at 15:39

0 Answers0