Skip to content

ML Models & Algorithms

Dendrogram

In shortA dendrogram is a tree diagram showing how hierarchical clustering merged items into groups, used to choose how many clusters to keep.

Updated 25 Oct 2026· 3 min read

A dendrogram is a tree diagram that shows how hierarchical clustering combined items into groups, step by step. The leaves at the bottom are individual items, such as keywords or customers, and each join higher up shows two groups being merged. The height of each join tells you how different the groups were when they merged, so reading the tree helps you decide how many clusters your data really has.

How it works

Most dendrograms come from agglomerative clustering, the bottom-up form of hierarchical clustering. Every item starts as its own cluster, the two closest clusters are merged, and the process repeats until a single cluster remains. The divisive form works top-down, starting with one cluster and splitting it, but agglomerative is the version most libraries implement. To read the result:

  • Vertical axis: the distance at which two groups merged. Joins near the bottom mean very similar items; joins near the top mean groups that are far apart.
  • Leaf order: leaves are arranged so branches do not cross. Two neighbouring leaves are only similar if they join low down.
  • Cutting: draw a horizontal line across the tree. Every branch the line crosses becomes one cluster. A long vertical stretch with no joins usually marks a natural number of clusters.
  • Linkage: the shape depends on how distance between groups is measured: single (closest pair), complete (farthest pair), average, or Ward’s method (smallest increase in within-cluster variance).

In Python, SciPy’s linkage function computes the merges and its dendrogram function draws them, while scikit-learn’s AgglomerativeClustering assigns the final cluster labels.

How it’s used in SEO and marketing

  • Keyword clustering by SERP overlap: our SERP automation guide builds an average-linkage hierarchy from shared top-ten URLs next to a hard clustering threshold. The dendrogram shows the near-misses the threshold splits apart.
  • Customer segmentation: the segmentation notebook applies Ward linkage to scaled RFM features, plots a truncated dendrogram of the last 30 merges with suggested cut heights, then labels segments with AgglomerativeClustering. The lesson recommends it when you do not know the number of segments upfront and want nested macro and micro segments.
  • Taxonomies and site architecture: nested branches map naturally onto categories and subcategories, or onto topic clusters and their supporting pages.
  • Content audits: pages that merge very low in the tree are candidates for near-duplicate or cannibalisation checks.

Example

Eight running-shoe keywords are clustered by SERP overlap. “trail running shoes” and “best trail running shoes” join almost at the bottom; “running shoes for flat feet” and “stability running shoes” join a little higher; the trail group and the support group only merge near the top. Cutting just below that top merge gives two clusters, each a candidate landing page. Cutting lower gives tighter groups that suit sections or supporting articles.

Limitations and things to watch

  • Trees with more than a few hundred leaves are hard to read. Truncate to the last merges or label clusters instead of items.
  • Merges cannot be undone, so an early poor merge stays in the tree.
  • Computing every pairwise distance gets slow and memory-hungry on large data; the segmentation lesson suggests the method for up to about 10,000 customers.
  • Different linkage rules can produce very different trees, so compare more than one.
  • Where to cut is a judgement call. Check a sample of clusters by hand before acting on them.

Learn it on MLforSEO

Where Dendrogram shows up on MLforSEO

Sources and further reading

Other terms from ML Models & Algorithms

See all 55 ML Models & Algorithms terms →