Clustering Data with Multiple Features
Agglomerative clustering produces a hierarchical clustering, in which each point moves from a single-point cluster to some final cluster.
Why Clustering Can Be Read as a History
Most clustering methods hand you a finished set of groups. You get the final clusters and little else. Hierarchical clustering works differently. It shows you the whole history of how the groups came together, so you can see what the data looks like at every stage on the way to the final answer, not only at the end.
This article follows that journey step by step. It starts with agglomerative clustering, the kind of clustering that produces a hierarchical clustering. It then shows how each intermediate stage is itself a valid clustering, and it ends with the tool that makes the whole history easy to read even when the data has many features.
Watching Points Merge Step by Step
Agglomerative clustering produces a hierarchical clustering, in which each point moves from a single-point cluster to some final cluster. The word agglomerative points to the direction of the work: pieces are gathered together into larger pieces.
The process begins with every data point in its own cluster containing just itself. From there, the process repeatedly combines clusters. Over many steps, the single-point clusters grow into bigger groups until they become the final clusters.
It helps to think of this as a journey rather than a single assignment. Every point travels from being a single-point cluster to belonging to some final cluster. No point is assigned once and forgotten. Each point's cluster changes as the process runs, and the final cluster it ends up in is the result of a whole sequence of earlier merges.
Tracing Four Points from Start to Finish
Four data points, A, B, C, and D, each begin as their own single-point cluster. Follow how they reach one final cluster.
- 1Start
Each point is its own cluster: {A}, {B}, {C}, {D}. That is four clusters.
- 2First merge
A and B join first, forming {A, B}. The clusters are now {A, B}, {C}, {D}.
- 3Second merge
C and D join next, forming {C, D}. The clusters are now {A, B} and {C, D}.
- 4Final merge
The two groups join at the top, forming {A, B, C, D}. Every point now belongs to one final cluster.
Each point moved from a single-point cluster to the final cluster through a sequence of three merges.
What Each Intermediate Step Contains
The key fact about the snapshots is that each intermediate step is itself a valid clustering of the data. Every step groups the same points, but it uses a different number of clusters than the step before it. A step with many small clusters is a fine-grained view. A step with fewer, larger clusters is a coarser view of the same data.
Read the table of snapshots carefully. The step with four clusters is the finest possible view of these four points. The step with two clusters is coarser, and the step with one cluster is the coarsest. Every one of these stages is a complete answer to the question of how the points are grouped, so none of them is a throwaway intermediate result.
Overlaying Every Clustering on One Plot
It is sometimes useful to look at all of these possible clusterings together. One approach is to overlay them on a single picture, so you can see how each cluster breaks up into smaller clusters as you move back through the history. The overlay makes the structure of the hierarchy visible at a glance.
The overlay gives a very detailed view. It shows how clusters split into smaller ones, and it lets you compare stages side by side. It has a hard limit, though. The overlay relies on the data being two-dimensional, meaning each point can be placed on a plane by two values. Because of that, it cannot be used on datasets with more than two features.
| Feature | Overlay of all clusterings | Dendrogram |
|---|---|---|
| Shows how clusters break up into smaller clusters | Yes | Yes |
| Works as a flat picture of points on a plane | Yes, for two features | Not required; drawn as a tree |
| Can be used with more than two features | No | Yes |
| Presents the structure as | Points on a plane | A tree-shaped diagram |
The overlay and the dendrogram answer the same question, but only the dendrogram extends to multidimensional data.
Reading a Dendrogram from Bottom to Top
The dendrogram answers the same kind of question as the overlay: how do the clusters break up into smaller clusters? The difference is that it presents this structure as a tree-shaped diagram rather than as points on a plane. Clusters that merge early appear close together in the diagram, and the branching shows which groups joined which others on the way up to the final cluster.
Read the tree from the bottom up to follow the merges in order. This matches the run traced earlier: A and B join first, C and D join next, and the two groups join at the top. Read it from the top down to see how the final cluster splits into smaller clusters.
A dendrogram is a tool for visualizing hierarchical clustering, and it can handle multidimensional datasets with more than two features. The tree does not need a horizontal and vertical axis for each feature. It records only which groups joined and in what order, so the same reading works whether the points have two features or many.
Common Mistakes When Reading the History
Common mistake Treating only the final cluster as the result
Why it failsThe final cluster is one stage of the process. Every intermediate step is itself a complete clustering of the same points.
Do this insteadLook at the sequence of clusterings, and note how many clusters each step contains.
Common mistake Assuming the overlay works for any number of features
What it looks likeTrying to draw an overlay for points described by three or more features on a flat plot.
Why it failsThe overlay depends on the data being two-dimensional, so it cannot be used with more than two features.
Do this insteadUse a dendrogram, which can handle datasets with more than two features.
Common mistake Reading the dendrogram from the top down only
Why it failsReading from the top down shows splits, but the merges happen in order when you read from the bottom up.
Do this insteadRead bottom to top to follow the merges in order, then top to bottom to see the splits.
Practice Tracing a Merge Sequence
Four points, W, X, Y, and Z, each start as a single-point cluster. In the first merge, W and X join. In the second merge, Y joins the group {W, X}. In the third merge, Z joins to form one final cluster. For each intermediate step, state how many clusters it contains, then state which merge happens at each step.
Hints
- Count the clusters before any merge. Each point starts as its own cluster.
- Each merge combines two clusters into one, so the cluster count drops by one per merge.
- Start with four clusters, then check your count after each of the three merges.
Key Takeaways
- Agglomerative clustering produces a hierarchical clustering in which each point moves from a single-point cluster to some final cluster through repeated merges.
- Each intermediate step is a complete, valid clustering of the same data with a different number of clusters, and the clusterings are nested inside one another.
- An overlay of all possible clusterings reveals how clusters break up, but it depends on two-dimensional data and cannot be used with more than two features.
- A dendrogram visualizes the merge history as a tree; reading bottom to top follows the merges in order, and it can handle datasets with more than two features.