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.
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
- What Machine Learning Clustering Is, and Where It Fits in SEO
- 10 Ways to Automate SERP Analysis with AI, including keyword clustering by SERP overlap
- Customer Segmentation with Machine Learning Using Three Clustering Approaches (Notebook)
- Introduction to Machine Learning for SEO, including the customer segmentation practical
Where Dendrogram shows up on MLforSEO
Learn it in a course
Try it yourself
- Coding Script or NotebookInternal Link Audit and Topic Clustering Notebook with Embeddings
- Coding Script or NotebookCustomer Segmentation with Machine Learning Using Three Clustering Approaches
- Code on GitHubSERP analysis with machine learning and AI (2026)
- Code on GitHubFree keyword clustering tool: SERP overlap + embeddings hybrid
Sources and further reading
Other terms from ML Models & Algorithms
- BERT (Bidirectional Encoder Representations from Transformers)Google's 2018 transformer language model that reads text in both directions to produce context-aware embedding…
- BERTopicA modular topic modelling technique that clusters transformer embeddings and labels each cluster with class-ba…
- BIRCH (Balanced Iterative Reducing and Clustering using Hierarchies)BIRCH (Balanced Iterative Reducing and Clustering using Hierarchies) clusters very large numeric datasets by s…
- BM25A classic ranking function that scores documents by how often query words appear, adjusted for word rarity and…
- Boyer-MooreA fast exact string-search algorithm that compares a pattern from right to left and skips ahead after mismatch…
- c-TF-IDFClass-based TF-IDF: treats each cluster as one document to find the words that best describe it, used by BERTo…
- Centroid-based ClusteringA clustering family that groups data around central points (centroids), each the average of its cluster's memb…
- Convolutional Neural Network (CNN)A deep learning architecture that scans data with small learned filters to detect local patterns; the classic…
- DBSCANDensity-based clustering that groups closely packed points, finds the number of clusters itself and labels iso…