Skip to content

Agglomerative Clustering Turns a Dataset Into a Merge Tree

Agglomerative clustering builds a tree out of a dataset from the bottom up. Begin with every observation as its own cluster. Find the two clusters that are least dissimilar, fuse them, and record the dissimilarity as the height of that fusion. Repeat until everything is one cluster. That is Algorithm 12.3 in James, Witten, Hastie, and Tibshirani, and the record of fusions is the dendrogram.

The algorithm hides one decision. A distance between two points is easy. A distance between two groups of points is not, so you must choose a linkage. The authors list four common ones: complete (the largest pairwise dissimilarity between the groups), single (the smallest), average (the mean of all pairwise dissimilarities), and centroid (the dissimilarity between the two cluster centers). They add that average and complete linkage are generally preferred over single linkage because they tend to yield more balanced dendrograms.

Try it by hand. Five points on a number line: 0, 1, 4, 6, and 9.5. The first fusion is the same under every linkage: 0 and 1 are 1 apart, so {0,1} forms at height 1. Next, 4 and 6 are 2 apart, so {4,6} forms at height 2. Now the choice matters. With single linkage, the distance between {0,1} and {4,6} is that of their nearest members, 1 and 4, which is 3; between {4,6} and 9.5 it is 6 to 9.5, which is 3.5. The smallest is 3, so {0,1} and {4,6} fuse. With complete linkage, use the farthest members: {0,1} to {4,6} is 0 to 6, which is 6, while {4,6} to 9.5 is 4 to 9.5, which is 5.5. The smallest is 5.5, so {4,6} fuses with 9.5 instead. Same five points, two different trees.

To get clusters out of the tree, you cut the dendrogram at a height. The authors add that clusters from a lower cut are nested inside clusters from a higher cut, and that on real data this nesting may be unrealistic, since the best split into two groups need not be the best split into three. Often, they say, the choice of where to cut is not clear.

The trap: treating "closest pair" as one fixed rule. It has no meaning until you name a distance and a linkage, and the tree you get depends on both.

Prof Rod's rule: report the distance and the linkage with the clusters, and try a second linkage before you trust a tree.

James, Witten, Hastie, and Tibshirani, An Introduction to Statistical Learning, 2nd ed., Section 12.4.2, Algorithm 12.3, and Table 12.3, pp. 521–526