ClusteringSample

Hierarchical clustering

Merges the closest clusters step by step, building a tree you can cut at any level.

Synthetic data, generated and trained in your browser.

Try this

  1. 01Click the dendrogram at different heights to change the number of clusters.
  2. 02On Moons, compare single linkage (follows chains) with complete linkage (prefers compact groups).
  3. 03Find the tallest vertical gap in the dendrogram: it suggests a natural number of clusters.

How it works

  1. 1Start with every point as its own cluster.
  2. 2Merge the two closest clusters, where "closest" depends on the linkage.
  3. 3Repeat until one cluster remains, recording each merge in a dendrogram.
  4. 4Cut the dendrogram at a height to get a clustering.

What the controls teach

Linkage
How distance between clusters is measured: closest pair (single), farthest pair (complete) or the average.
Clusters (cut)
Where to cut the tree. Each cut lower down adds one more cluster.

Use it when

  • Small data where the hierarchy itself is informative

Avoid it when

  • Large datasets (the cost grows quickly)

More in Clustering