How do single, complete, average and Ward linkage decide which clusters merge next?
answer
- min, max, mean, and variance
- one rule follows chains of neighbours
- one rule is ruled by the extreme pair
- Ward costs the rise in within-cluster spread
- size factor times squared centroid gap
basics
~20 sEach rule collapses the distances between two clusters' members into one number, and the closest pair merges. Single takes the nearest cross-pair, complete the farthest, average the mean; Ward merges whichever pair adds least to within-cluster sum of squares.
solid answer
~40 sAll four are rules for collapsing the cross-cluster distances between two groups into a single number, and the pair with the smallest number merges next. Single linkage takes the minimum over all cross-cluster pairs, so it can follow long, non-convex shapes but suffers chaining: a thin trail of intermediate points welds two dense groups into one. Complete linkage takes the maximum, which yields compact clusters of roughly equal diameter and is easily distorted by one outlier. Average linkage takes the mean of all cross-cluster distances and behaves between the two. Ward is different in kind — it merges the pair whose union increases the total within-cluster sum of squares least, which favours compact, similar-sized groups and makes it the common default. Ward is defined through squared Euclidean distance, so unscaled features silently dominate it.
code
python · 20 linesfrom itertools import product
A = [(0.0, 0.0), (0.2, 0.4)]
B = [(1.0, 0.1), (3.0, 0.0)]
def dist(p, q):
return ((p[0] - q[0]) ** 2 + (p[1] - q[1]) ** 2) ** 0.5
cross = [dist(p, q) for p, q in product(A, B)]
print('single ', round(min(cross), 3))
print('complete', round(max(cross), 3))
print('average ', round(sum(cross) / len(cross), 3))
def sse(pts):
cx = sum(p[0] for p in pts) / len(pts)
cy = sum(p[1] for p in pts) / len(pts)
return sum((p[0] - cx) ** 2 + (p[1] - cy) ** 2 for p in pts)
# Ward: the rise in total within-cluster sum of squares caused by merging
print('ward ', round(sse(A + B) - sse(A) - sse(B), 3))go deeper
Memorise the three summaries first: nearest cross pair, farthest cross pair, mean of all cross pairs. Then be able to name chaining as the thing that goes wrong with the nearest-pair rule.
Expect to derive the behaviour from the definition rather than recite it: why a min rule can walk along a bridge, why a max rule refuses elongated clusters, and why Ward's size factor produces balanced groups. Mention that Ward assumes squared Euclidean distance.
Show that linkage choice is a hypothesis about cluster shape and that you check it. Say what you would look for in the tree and the data before defending a choice, and flag the scaling step that quietly decides the answer for Ward and complete linkage.
Own the framing that no linkage is neutral: each imposes a prior about shape and balance, and Ward's equal-size bias can manufacture a tidy story the business then acts on. Argue for reporting how conclusions move under an alternative rule rather than shipping one tree.
## The shared frame A linkage rule answers one question: given two clusters `A` and `B`, and the distances between every point of `A` and every point of `B`, how far apart are the clusters? Every agglomerative run then merges whichever current pair scores lowest. The rules differ only in how they summarise the same set of cross-cluster distances, and that single choice determines what shape of cluster the method can find. ## Single linkage — the minimum `d(A, B) = min` over all cross pairs. Two clusters are close if *any* member of one is close to *any* member of the other. This makes single linkage a shape-agnostic method: it will happily recover a crescent, a ring or a snake, because it only ever needs a chain of near neighbours to hold a cluster together. The same property is its notorious failure, called **chaining**. Imagine soil samples from two clearly distinct field zones, with a thin trail of transitional samples collected along the track between them. Each consecutive trail sample is near its neighbour, so single linkage walks the trail step by step and merges the two dense zones into one sprawling cluster at a very low height. The dendrogram gives it away: instead of two deep branches you see a lopsided comb, with singletons peeling onto a growing blob one at a time. Single linkage is also the linkage most damaged by a handful of noise points, because one bridging point is enough. A useful piece of structure: single linkage is exactly a minimum spanning tree computation. Cutting the tree at height `h` gives the connected components you would get by deleting every MST edge longer than `h`. ## Complete linkage — the maximum `d(A, B) = max` over all cross pairs. Two clusters merge only if their *most distant* members are still tolerably close. The effect is the opposite of chaining: complete linkage produces tight, roughly equal-diameter clusters and refuses to build elongated ones, because extending a cluster raises its diameter and so raises the cost of every further merge. Its weakness follows from the same definition — the score depends on one extreme pair, so a single outlier attached to a cluster inflates that cluster's distance to everything and can push the tree into a poor arrangement. It also tends to split a genuinely elongated group into several pieces. ## Average linkage — the mean `d(A, B) = mean` of all cross pairs (the classical UPGMA rule). Because it averages over every pair rather than trusting an extreme, it is far more robust than either min or max, and its behaviour lies between them: less chaining than single, less fragmentation of elongated shapes than complete. Note precisely what is averaged — the *pairwise distances*, not the two centroids. Averaging centroids is a different rule (centroid linkage), and centroid linkage can produce inversions, where a merge is drawn below an earlier one, which single, complete, average and Ward never do. ## Ward linkage — the variance criterion Ward does not summarise cross-cluster distances at all. Define the within-cluster sum of squares of a cluster as the summed squared distance from its members to its own mean. Ward merges the pair whose union raises the *total* within-cluster sum of squares by the least: `cost(A, B) = SSE(A union B) - SSE(A) - SSE(B)` which has a closed form: `cost(A, B) = (n_A * n_B / (n_A + n_B)) * squared distance between the centroids of A and B` Read that formula and Ward's character falls out. The centroid distance is scaled by a size factor, so merging two large clusters is expensive even when their centres are close. Ward therefore produces compact, roughly equal-sized clusters and resists both chaining and the lopsided one-point-at-a-time tree. That is why a Ward dendrogram drawn beside a heatmap of, say, 60 tumour gene-expression profiles reads so cleanly: balanced branches, visually blocky groups. It is also why Ward can be misleading — if the real structure is one large group and one tiny group, Ward is biased against reporting it, and it will impose equal-sized blocks on data that has none. Two practical consequences. First, the derivation is in terms of squared Euclidean distance, so Ward is not defined for an arbitrary distance function; feeding it precomputed non-Euclidean distances produces numbers, not a valid criterion. Second, because it works on squared Euclidean geometry, unscaled features dominate: a variable measured in thousands will drive every merge unless the features are standardised first. Complete linkage inherits the same scaling sensitivity; single linkage is affected too, but its min-based rule cares about local neighbourhoods rather than global spread. ## Choosing Ward first when you expect roughly convex, comparable-sized groups and have scaled the features. Average linkage when you want a robust general-purpose tree without Ward's equal-size bias. Complete linkage when tight diameter matters and outliers have been handled. Single linkage when the clusters are genuinely elongated or connected-by-density, and only after asking whether a bridge of transitional points could exist in the data.
- Why can Ward linkage not be used with an arbitrary precomputed distance matrix?Ward's criterion is derived from within-cluster sum of squares, which is defined through squared Euclidean geometry: its merge cost equals the size-weighted squared distance between centroids. With a distance that does not come from a Euclidean embedding, there are no meaningful centroids and the identity no longer holds, so the numbers the algorithm produces are not the variance increase it claims to minimise.
- Your data has one large group and one genuinely small one. Which linkage would you avoid?Ward, as the sole choice. Its merge cost carries a factor n_A * n_B / (n_A + n_B), which makes absorbing a small cluster cheap and merging two large ones expensive, so it tends to split large groups and hide small ones inside them. Average linkage has no such size term and reports unequal group sizes more faithfully.
- How would you spot chaining from the dendrogram alone, without plotting the data?Look for a lopsided comb: instead of two or more deep branches meeting high up, one branch grows continuously as single leaves attach to it at steadily increasing but never large heights. That staircase means the cluster is being extended one near neighbour at a time rather than joined to another dense group.
- Does feature scaling change the tree for every linkage rule?It can change all of them, since scaling changes the distances themselves, but the exposure differs. Ward and complete linkage are strongly affected because both respond to global spread, so a variable measured in thousands drives every merge. Single linkage is the least distorted, since its min-based rule reacts to local neighbourhoods, though even there a dominant feature can create or destroy bridges.
Single linkage asks whether the two groups have any pair of close neighbours; complete linkage asks whether their most distant members could still bear to share a room.
saying these in an interview costs you the question
- Describes Ward as a distance between points, not a merge cost
- Says average linkage averages the two cluster centroids
- Calls single linkage best because it finds any shape
- Runs Ward or complete linkage on unscaled features
- Believes complete linkage is robust to a single outlier