Unlike k-means, the method does not require a cluster count before building the hierarchy. Afterward, a horizontal cut through the dendrogram determines the number of groups. A large vertical gap can suggest a useful cut, but it is evidence to inspect, not proof of a natural number of clusters.
Linkage defines “closest”
- Single: minimum distance between any pair across the two clusters. It can connect elongated groups, but a chain of nearby points may join otherwise distinct groups.
- Complete: maximum distance between cross-cluster pairs. It tends to form compact groups, but one distant point can delay a merge.
- Average: mean cross-cluster distance. It is a compromise between the two definitions.
- Ward: merges the pair that produces the smallest increase in within-cluster squared error. It favors compact groups and is available only with compatible Euclidean distances.
Try each available choice in Linkage. Then move Cut height and watch the flat cluster count change while the merge tree stays the same. The visualizer offers Single, Complete, and Average; Ward is described here for comparison.
Worked example: read a cut
Suppose two tight groups are far apart. Merges within each group occur at small heights; the final merge between groups occurs much higher. A cut between those heights returns two clusters. If instead the dendrogram has no clear gap, the data may not support a compelling cluster count, or the chosen distance and linkage may not match the structure.
The left-to-right order of leaves is arranged for drawing and does not rank similarity. Read branch joins and heights, not which leaves happen to appear next to each other.
Limits and practical choices
Agglomerative merges are greedy and irreversible: an early merge remains in every higher level of the tree. Distance-based results are sensitive to feature scale, so scale features when units differ. Many implementations require pairwise-distance storage that grows quadratically with the number of observations, limiting the method on large datasets.
Choose linkage and distance based on the shape and meaning of the data, and validate any selected clusters against domain knowledge or a downstream task. Hierarchical clustering can show structure at several resolutions; it does not prove that the data contains discrete natural groups.