← Learn AI
C_000186 · machine learning · foundation

Hierarchical Clustering

Building a tree of nested clusters by successively merging or splitting, visualised as a dendrogram.

Step 1 of 4

In words

What it is, why it matters, and what it is like.

Why am I learning this?

This lets you find natural groupings in data without guessing how many groups exist ahead of time. Imagine you have a list of customer profiles and you want to segment them for marketing, but you do not know if there are 3, 5, or 10 distinct types of customers. This method builds a complete map of relationships, allowing you to explore the structure of the data first and decide on the number of groups only after seeing how tightly everything connects. You can then move on to other techniques that require a fixed number of groups, like k-means, with a clearer understanding of your data.

The idea, in plain terms

Imagine a scattered collection of points on a map. Hierarchical clustering starts by treating each point as its own tiny group. Then, it repeatedly finds the two groups that are closest together and merges them. Each merge creates a larger group. You repeat this until everything is one big group. The result is a tree diagram, which we will call a dendrogram, that shows every merge from the bottom (where every point is alone) to the top (where everyone is together). This tree is the product, not just a flat list of groups. You can 'cut' this tree at any height to get a specific number of clusters: cut low near the bottom and you get many small groups; cut high up and you get a few large ones. You never need to decide the number of groups in advance. For example, if you have 10 points, you might cut the tree to get 3 groups after seeing which natural separations exist. The same idea works in reverse: starting with one big group and splitting it, but the merging version is most commonly used.

An analogy

You are organizing a large extended family for a reunion. You begin with every person as their own separate unit. Then you look for the two people who are closest — say, two siblings who both live in the same town — and you group them. Now you have a new unit: that sibling pair. Next, you find the closest pair among all your units, which might be the sibling pair and a cousin who lives nearby, so you merge again. Over many steps, you merge the closest units until the whole extended family is one tree. The key is that you never said 'I want five families' at the start. You just kept merging the closest. The resulting family structure lets you decide later, after seeing the whole layout, that you want to group at the level of immediate households, or at the level of the whole clan. Caveat: unlike real families where connections are fixed by blood, these clusters are formed purely by the distance metric you choose.

Definition

Hierarchical clustering is a method that builds a nested tree of groups by repeatedly merging the two closest groups based on a rule for measuring distance between sets, resulting in a dendrogram that visualizes all possible groupings at once.

Where this sits

This sits beside k-means clustering, which also groups data but requires you to fix the number of groups beforehand and assumes groups are roughly spherical. It differs from DBSCAN, which labels some points as noise rather than placing every point in a nested structure. Both methods fall under Unsupervised Learning, where there is no predefined label to predict, making validation more challenging because you lack ground truth.

Signal from the Frontier

Get the next essay on mind, machine, and meaning

Essays at the intersection of AI, philosophy, and Indian governance. No promotional content.

We'll send a one-click sign-in link to confirm. No password needed.

Views expressed are personal and do not represent the Government of India or the Government of Uttarakhand.