How do you interpret a dendrogram to choose where to cut the tree?

Last updated 11 November 2026

The vertical axis of a dendrogram is the merge distance (dissimilarity), so you cut horizontally where there is a large vertical gap between successive merges: that gap means you would have to join clusters that are far apart, so the clusters below it are well separated.

  • Reading the tree:

    • Leaves are observations; each horizontal bar is a merge drawn at the height (distance) where it happened.

    • Horizontal position of leaves is arbitrary. Similarity is read from merge height, not from how close two leaves sit on the x-axis.

    • A horizontal line at height h crosses k vertical branches, which gives k clusters.

  • Choosing the cut:

    1. Largest-gap heuristic: find the longest vertical stretch with no merges and cut through it. This is the most stable k across a range of thresholds.

    2. Elbow on merge heights: plot the sorted merge distances and look for a sudden jump. This is the hierarchical analogue of the k-means elbow.

    3. Distance threshold: cut at a domain-meaningful distance, e.g. fcluster(Z, t, criterion='distance') in SciPy or distance_threshold in scikit-learn.

    4. Validate the candidate k values with internal metrics (silhouette) or with business usefulness.

  • Caveats:

    • The heights depend on the linkage method. Ward produces exaggerated top-level gaps; single linkage produces compressed, chained trees.

    • A single flat cut assumes all clusters share a similar scale. Clusters of very different density may need non-uniform (dynamic) cuts.

[lang:python] from scipy.cluster.hierarchy import linkage, fcluster import numpy as np Z = linkage(X, method='ward') gaps = np.diff(Z[:, 2]) # jumps between successive merge heights i = gaps.argmax() t = (Z[i, 2] + Z[i + 1, 2]) / 2 # cut in the middle of the largest gap labels = fcluster(Z, t, criterion='distance')

  • https://vizlearn.in/machine_learning/hierarchical_clustering.html
  • https://medium.com/@sachinsoni600517/mastering-hierarchical-clustering-from-basic-to-advanced-5e770260bf93
  • https://github.com/Devinterview-io/cluster-analysis-interview-questions
All Clustering interview questions