intermediateadvanced-ml

Hierarchical Clustering

Build a family tree of your data instead of committing to one fixed number of clusters upfront.

Key Points

What it is

Hierarchical clustering builds a tree-like structure (dendrogram) of nested clusters by either repeatedly merging the closest pairs of points/clusters (agglomerative, bottom-up) or repeatedly splitting the data (divisive, top-down). You decide the number of clusters afterward by cutting the tree at a chosen height.

Why it exists

K-Means forces you to commit to a fixed number of clusters upfront, which is often unknown. Hierarchical clustering exists to reveal the full nested structure of the data at every possible granularity, letting you decide how many clusters make sense after seeing the whole picture.

Intuition

Think of building a family tree from a room full of strangers. You start by pairing up the two most similar people, then treat that pair as one unit and find the next closest match — repeating until everyone is one giant family. The dendrogram is that family tree; cutting it at different heights gives you different numbers of 'family groups.'

How it works

  1. Start with every point as its own cluster

    Treat each data point as a singleton cluster.

  2. Merge the closest pair

    Find the two closest clusters (using the chosen linkage method) and merge them into one.

  3. Repeat

    Keep merging the closest pair of clusters until only one cluster containing all points remains.

  4. Cut the dendrogram

    Choose a height to 'cut' the resulting tree, which determines the final number of clusters.

When to use

When not to use

Common mistakes

In practice

Used in bioinformatics (gene expression clustering), document/topic organization, and any exploratory analysis where understanding nested group structure matters more than getting one fixed number of clusters quickly.

Was this concept helpful?

Spot an error or gap? Suggest an edit →

Related concepts

k-means-clusteringdbscanclustering-evaluation-silhouette-score
Chirp at me!