What does a dendrogram show, and how does agglomerative clustering build one?
answer
- bottom-up, one merge at a time
- the tree stores every granularity
- height on the axis is a distance
- leaf order can be flipped freely
- no k chosen before the run
basics
~20 sA dendrogram is a tree recording the order and distance at which clusters merge. Agglomerative clustering starts with every observation as its own cluster and repeatedly merges the two closest ones, drawing each merge at the distance it happened.
solid answer
~50 sAgglomerative clustering starts with every observation as its own cluster and repeatedly merges the two closest clusters until one remains. The dendrogram is the record of that process: each horizontal join is one merge, and its height on the vertical axis is the distance at which those two groups were joined. Short joins mean tightly related groups; a long vertical stretch below a join means the two branches under it were well separated before anything forced them together. Because the whole nesting is stored, you do not fix the number of clusters in advance — you cut the tree afterwards. One caveat that trips people up: the left-to-right order of the leaves is arbitrary, since either branch of any join can be flipped without changing the tree, so horizontal adjacency is not evidence of similarity.
go deeper
Be ready to describe the loop in one breath: every point starts alone, the two closest clusters merge, repeat. Then say what the two axes of the dendrogram mean and note that leaf order is arbitrary.
Explain why the heights are monotone for the usual linkage rules, and why the output is a nested family of partitions rather than a single clustering. Expect a follow-up on divisive clustering and its cost.
Show that you know the greedy, no-undo nature of the merge sequence and what it implies: early merges driven by a handful of odd points shape the whole upper tree, so the picture deserves a stability check before anyone reorganises work around it.
Frame when a hierarchy is the right deliverable at all. Its selling point is that one run exposes every granularity for a stakeholder conversation; its cost is quadratic memory and irrevocable merges, so it suits exploration and taxonomy work more than a recurring production job.
## The algorithm Agglomerative (bottom-up) hierarchical clustering begins with `n` clusters, one per observation, and then repeats one step: find the two clusters that are closest under a chosen linkage rule, merge them, and record the distance at which they merged. After `n - 1` merges everything sits in a single cluster and the run ends. The important consequence is that the output is not a partition. It is a nested family of partitions, from `n` singletons at the bottom to one all-inclusive group at the top, with the property that every cluster at one level is wholly contained in a cluster at the next. That nesting is what makes the result drawable as a tree. ## Reading the picture A dendrogram plots the observations as leaves along one axis and merge distance along the other (conventionally vertical). Each merge is drawn as a bracket joining two subtrees, and the bracket sits at the height equal to the linkage distance between the two clusters at the moment they were joined. From that, three readings are legitimate: - **Height of a join** = how far apart the two groups were when merged. Low joins are strong groupings; high joins are reluctant ones. - **Vertical gaps** = separation. If nothing merges between height 1.2 and height 4.0, the structure present just below 4.0 survived a wide range of thresholds, which is the visual signature of well-separated groups. - **Membership** = which leaves sit under a given bracket. That is the cluster the bracket defines. And one reading is illegitimate: **leaf order carries no information**. At every join you may swap the left and right subtree and the tree is unchanged, so there are `2^(n-1)` equally valid orderings of the leaves. Two leaves printed next to each other may be joined only at the very top of the tree. Plotting tools pick some ordering, and people routinely over-interpret it. ## Monotone heights For the standard rules — single, complete, average and Ward linkage — merge heights never decrease as you go up the tree, because merging two clusters can only push the next-nearest distance up or leave it the same. This is why the picture reads cleanly and why a horizontal line across it means something. Some less common rules (centroid and median linkage) are not monotone and can produce inversions, where a later merge is drawn *below* an earlier one. ## Agglomerative versus divisive The top-down mirror image is divisive clustering: start with one cluster containing everything and recursively split. It is far rarer in practice, and the reason is combinatorial. Splitting a group of `m` points optimally means searching `2^(m-1) - 1` possible two-way splits, so exact divisive clustering is intractable and practical versions (DIANA is the classic one) rely on heuristics for choosing what to split off. Agglomerative clustering, by contrast, only ever has to scan pairs of current clusters. The one theoretical argument for divisive methods is that the top of the tree — the coarse structure most people actually use — is decided by a global look at the data rather than by a long chain of local greedy merges. ## What you get out of it Because a hierarchy is not a clustering, using the result requires a second decision: cutting the tree at a height, or equivalently stopping the merge sequence after `n - k` merges to leave `k` clusters. That is a separate step with its own judgment. The compensating advantage is that a single run gives you every granularity at once — you can inspect a two-cluster view and a twelve-cluster view of the same data without refitting anything, which is why hierarchical clustering is so common in exploratory work where nobody has committed to a number yet. The costs are also structural. The method is greedy and has no undo: a merge made early is never revisited, even if later evidence shows it was wrong. And it needs the pairwise distances among all current clusters, which is why memory grows quadratically with the number of observations.
- How does divisive clustering differ, and why is it used far less often?Divisive clustering is top-down: it starts with one cluster holding everything and recursively splits it. Splitting a group of m points optimally means searching 2^(m-1) - 1 possible two-way splits, so exact divisive clustering is intractable and practical versions lean on heuristics. Agglomerative clustering only ever compares pairs of current clusters, which is far cheaper, so it dominates in practice.
- Two leaves are printed side by side at the bottom of the tree. What may you conclude?Nothing on its own. Either branch of any join can be swapped without changing the tree, so there are 2^(n-1) valid leaf orderings and the plotting routine simply chose one. Two adjacent leaves may only be united at the very top. What is meaningful is which bracket the leaves sit under, and at what height that bracket sits.
- Can an early merge be undone later if it turns out to be wrong?No. Agglomerative clustering is greedy and irrevocable: once two clusters merge, every subsequent step treats them as one object. That is why a few misleading points early on can shape the whole upper tree, and why the method has no equivalent of the iterative reassignment that partition-based clustering performs.
Read it like a family tree from the bottom up: the height at which two branches join tells you how far back you have to travel before the two groups share an ancestor.
saying these in an interview costs you the question
- Claims the dendrogram itself tells you the number of clusters
- Reads left-to-right leaf adjacency as similarity
- Thinks you must fix the cluster count before running it
- Confuses a join height with the size of the merged cluster
- Says merges are revisited and corrected on later passes