Hierarchical Clustering Overview
What you'll learn: How hierarchical clustering builds nested groups of clusters and when to use it instead of k-means.
The Core Idea
Hierarchical clustering creates a tree-like structure (called a dendrogram) showing how data points group together at different levels of similarity. Unlike k-means, you don't need to specify the number of clusters upfront—you can cut the tree at different heights to get different numbers of clusters.
Two Approaches
Agglomerative (Bottom-Up)
Start with each point as its own cluster, then repeatedly merge the two closest clusters until everything forms one big cluster. Think of it like building a family tree backward: individuals → families → communities → cities.
Divisive (Top-Down)
Start with all points in one cluster, then repeatedly split clusters until each point is alone. Less common in practice because it's computationally expensive—imagine trying to figure out the best way to divide a whole city into neighborhoods, then blocks, then houses.
When to Prefer Hierarchical Over K-Means
Use hierarchical clustering when:
- You don't know K in advance and want to explore different granularities
- You need the hierarchy itself (e.g., taxonomy creation, evolutionary trees)
- Your data has nested structure (departments within companies within industries)
- You have small to medium datasets (hierarchical scales poorly to millions of points)
K-means is better for large datasets with clear, non-nested spherical clusters.
Key Takeaway: Hierarchical clustering builds a tree of nested clusters (agglomerative merges up, divisive splits down), letting you explore multiple clustering solutions without pre-specifying K—ideal when cluster structure is hierarchical or unknown.