Hierarchical Clustering
Builds a tree of clusters by repeatedly merging the two closest groups, so you can cut the tree at any level to get as many clusters as you like.
Also agglomerative clustering · dendrogram · linkage · Ward's method
Start with every person as their own family. Join the two most similar people, then the next most similar pair or group, and so on, until everyone is one big family tree.
Where it fits
+All relationships as a list
Is a kind of / part of
How it works
Instead of producing one flat set of groups, hierarchical clustering produces a whole family tree of groups, called a dendrogram.
The common, bottom-up (agglomerative) version:
- Start with each point as its own cluster.
- Find the two closest clusters and merge them.
- Repeat until everything is in one cluster.
“Closest” between two groups needs a definition, called the linkage:
- Single: distance between the two nearest members. Can form long chains.
- Complete: distance between the two farthest members. Gives compact clusters.
- Average: the mean distance between all pairs.
- Ward: merge the pair that increases within-cluster variance the least, similar to what k-means optimizes.
To get, say, five clusters, cut the tree at the height where it has five branches. Long vertical lines in the dendrogram suggest natural places to cut.
It is ideal for exploring smaller datasets with nested structure. For millions of points, k-means or DBSCAN scale better.
Everyday use cases
- Case 01
Biology
Building family trees of species or grouping genes with similar expression patterns into heatmaps.
- Case 02
Organizing documents
Grouping news articles into topics and sub-topics without choosing a number of topics upfront.
Strengths, weaknesses and when to use it
Strengths
- No need to fix the number of clusters in advance; the dendrogram shows structure at every scale.
- Works with any distance measure.
Weaknesses
- Slow and memory-hungry for large datasets.
- Merges are greedy and never undone; results depend strongly on the linkage choice.
When to use itFor small to medium datasets where nested structure matters, or to explore how many clusters make sense.
Compare with
Check yourself
- Q01
What is a dendrogram?
Show answer
A: A tree diagram showing the order in which clusters merged