Hierarchical Clustering

Agglomerative clustering with linkage methods. Builds a hierarchy of clusters by iteratively merging the closest pairs. Supports single, complete, average, and…

Builds a hierarchy of clusters by iteratively merging the closest pairs. Supports single, complete, average, and Ward linkage methods.

What Is Hierarchical Clustering?

Hierarchical clustering builds a tree-like hierarchy (dendrogram) of nested clusters by iteratively merging the two closest clusters. Unlike K-Means, it does not require specifying K in advance — the dendrogram can be 'cut' at any level to produce different numbers of clusters, enabling exploratory analysis.

Linkage methods define how inter-cluster distance is measured: Single linkage uses the minimum pairwise distance (tends to produce elongated chains), Complete linkage uses the maximum (compact clusters), Average linkage uses the mean, and Ward's method minimizes the total within-cluster variance (usually produces the most balanced clusters).

The merge history table records which clusters were combined at each step and the distance at which the merge occurred. Large jumps in merge distance suggest natural cluster boundaries. Agglomerative (bottom-up) clustering starts with each point as its own cluster; divisive (top-down) starts with one cluster and splits.

Formula: Single linkage: d(A,B) = min{d(a,b) : a∈A, b∈B} Complete linkage: d(A,B) = max{d(a,b) : a∈A, b∈B} Average linkage: d(A,B) = (1/|A||B|) ΣΣ d(a,b) Ward: ΔV = (nₐnᵦ)/(nₐ+nᵦ) ‖μₐ − μᵦ‖²

Example Calculation

Points: A(0,0), B(1,0), C(4,0), D(5,0). Single linkage: Step 1 merge A+B (dist=1), Step 2 merge C+D (dist=1), Step 3 merge {A,B}+{C,D} (dist=3). Cutting at distance 2 gives 2 clusters: {A,B} and {C,D}.

When to Use This Calculator

Common Mistakes to Avoid

How to Interpret Results

Related Standards & References

Frequently Asked Questions

Which linkage method should I use?

Ward's method is the most popular default — it minimizes variance and tends to produce compact, evenly-sized clusters (similar to K-Means results). Use Complete linkage for compact clusters when Ward is not appropriate. Avoid Single linkage unless you expect chain-like cluster shapes, as it is prone to the 'chaining effect' that merges distinct clusters through outlier bridges.

How do I decide where to cut the dendrogram?

Look for the largest gap in merge distances — this indicates a natural cluster boundary. Alternatively, set a desired number of clusters based on domain knowledge. The inconsistency coefficient (comparing each merge distance to the average of nearby merges) can also automate the decision. Visualizing the dendrogram is the most intuitive approach.