Hierarchical Methods
1. Idea
Hierarchical clustering creates a nested sequence of clusters (a tree-like decomposition of the data) instead of a single flat partition. Two directions:
| Approach | Starts from | Proceeds to | Name |
|---|---|---|---|
| Agglomerative (bottom-up) | Each object = one cluster | One cluster containing all objects | AGNES |
| Divisive (top-down) | All objects in one cluster | Each object its own cluster | DIANA |
Because they produce a full hierarchy, the user can obtain any number of clusters by cutting the dendrogram at a chosen level.
2. Agglomerative Algorithm (AGNES)
1. Place each of the n objects in its own cluster -> n clusters
2. Compute the distance matrix between clusters
3. repeat
merge the two clusters with the smallest distance (or highest similarity)
update the distance matrix for the new cluster
until all objects are in one cluster (or the stopping condition is met)
4. Output the dendrogram; cut it to obtain k clusters
Complexity is the main drawback: at least time (distance matrix) and space; naive implementations are .
3. Inter-Cluster Distance (Linkage) Measures
| Linkage | Distance definition | Shape bias | Handles non-globular? | Cost update |
|---|---|---|---|---|
| MIN / single link | Distance between the closest pair of points in the two clusters | Can follow elongated, chained clusters | Good for non-elliptical shapes, but sensitive to noise/bridges | Simple: |
| MAX / complete link | Distance between the farthest pair | Tends to produce compact equal-diameter clusters | Biased toward globular shapes, breaks large clusters | |
| Average link (UPGMA) | Average of distances between all pairs (one from each cluster) | Compromise | Reasonable general purpose | weighted update |
| Centroid / Ward | Distance between centroids; Ward's method merges the pair that minimises the increase in total within-cluster variance | Globular; Ward is the most accurate on numeric, similarly sized clusters | Not for non-globular | Needs recomputation of centroids |
Formally for clusters :
Ward's merging cost:
4. Numeric Example — Points on a line
Points at 1-D positions 1, 2, 5, 9, 10 (distance = absolute difference).
Distance matrix:
| 1 | 2 | 5 | 9 | 10 | |
|---|---|---|---|---|---|
| 1 | - | 1 | 4 | 8 | 9 |
| 2 | - | 3 | 7 | 8 | |
| 5 | - | 4 | 5 | ||
| 9 | - | 1 | |||
| 10 | - |
AGNES with MIN link:
Step 1: merge {1,2} (d = 1) -> clusters: {1,2}, {5}, {9}, {10}
Step 2: merge {9,10} (d = 1) -> clusters: {1,2}, {5}, {9,10}
Step 3: merge {1,2}-{5} d = 3 ; {9,10}-{5} d = 4 -> merge {1,2,5}
Step 4: merge {1,2,5}-{9,10} d = min|5-9| = 4 -> one cluster
Dendrogram (heights): (1,2) at 1 ; (9,10) at 1 ; (5) attaches at 3 ; final merge at 4
Obtained partition: cut at height 3.5 → two clusters {1, 2, 5} and {9, 10}.
AGNES with MAX link gives a different merge order at step 3 — merging {1,2} with {5} has distance 4, while {5} with {9,10} has distance max|10-5| = 5, so the final merge of {1,2,5} and {9,10} happens at ; the two-cluster solution is the same here, but complete link avoids long chains in general.
5. BIRCH — Scalable Hierarchical Clustering
BIRCH (Balanced Iterative Reducing and Clustering using Hierarchies) handles large datasets in one scan using a CF (Clustering Feature) tree.
A CF-triple summarises a cluster of points:
Additivity theorem — CFs can be merged: , giving compact, incremental summaries.
Derived statistics:
CF-tree structure:
| Parameter | Meaning |
|---|---|
| Branching factor | Maximum number of children per non-leaf node |
| Threshold | Maximum radius (diameter) of a sub-cluster stored at a leaf |
| Leaf node | Holds up to micro-clusters (CF entries) |
Phases: (1) build CF-tree from data in one scan, inserting each point into the closest leaf entry and splitting nodes only when the tree grows (incremental, similar to a B+-tree); (2) optionally condense the tree by increasing ; (3) cluster the leaf CF entries with an in-memory algorithm (agglomerative or k-means); (4) optionally refine with more passes.
Complexity (linear) — the strength of BIRCH. Limitation: order-sensitive and only good for spherical (radius-based) clusters; it cannot recover non-globular shapes.
Worked CF example — points (3,4) and (4,5):
6. ROCK — Categorical / Categorical-Attribute Hierarchical Clustering
For boolean and categorical attributes, distance is replaced by links: two points are neighbours if their similarity exceeds a threshold ; link(p_i, p_j) = number of common neighbours.
ROCK merges the pair with the highest goodness; keeps clusters about equal in size. It is the hierarchical analogue of a Jaccard-based similarity method.
CHAMELEON (a third approach) first builds a -nearest-neighbour graph and then merges clusters using relative interconnectivity and relative closeness, which lets it find clusters of arbitrary shape, density and size:
7. Divisive Hierarchical Clustering (DIANA)
- Put all objects in one cluster.
- Find the object with the largest average dissimilarity to all others; move it to a new cluster; then repeatedly move objects that are closer (on average) to the new cluster than to the old one, until the split is stable.
- Recurse on each resulting cluster.
Divisive methods are needed when the interesting structure is at the top of the hierarchy (a few big clusters), but they are far more expensive than agglomerative ones: evaluating all possible first splits is prohibitive, so heuristics are used.
8. Advantages and Limitations
Advantages
- No need to pre-specify ; the dendrogram gives the whole nested solution.
- Deterministic (no random initialisation), easy visualisation and interpretability.
- Any distance/linkage can be plugged in; handles mixed data with suitable measures.
- Good exploratory tool; the tree itself is a compact summary of similarity structure.
Limitations
- Poor scalability: or worse in time and memory — too slow for millions of objects (hence BIRCH/CF-tree, ROCK, CHAMELEON).
- Merges are irreversible — an early wrong decision can never be undone.
- Local greedy decisions; sensitive to the linkage criterion and to noise/outliers (single-link especially).
- Different linkages give different clusters → choice is subjective.
9. Exam Points
- Explain AGNES and DIANA with algorithms; draw the dendrogram — 10 marks (frequent).
- Solve a given distance matrix by agglomerative clustering with single link — 10 marks (very frequent numerical).
- Explain MIN/MAX/average link and their bias; state why single link suffers the chaining effect — 5-7 marks.
- Explain BIRCH with CF-triple, CF-tree parameters , , and phases, plus a small numerical for — 10 marks.
- Short note on ROCK vs CHAMELEON — 5 marks.