Clustering discovers natural groupings in unlabelled data. Run k-means step by step, build a dendrogram by merging, weigh the trade-offs and spot outliers โ then test yourself with 10 questions.
Clustering puts similar objects in the same group and dissimilar ones apart โ with no labels to learn from. Good clusters have high intra-cluster similarity and low inter-cluster similarity. It's unsupervised: the structure is discovered, not taught.
k-means repeats two steps until nothing moves: assign each point to its nearest centroid, then update each centroid to the mean of its points. Press Step to watch one round, Run to animate to convergence, and change k or resample the data.
Start with every point as its own cluster, then repeatedly merge the two closest clusters until one remains. The merge order draws a dendrogram; cut it at a height to get any number of clusters.
Linkage = how cluster distance is measured: single (nearest pair), complete (farthest pair), average, or Ward (variance).
The opposite: start with all points in one cluster and recursively split. It's more expensive but can capture large structure first. Both produce a hierarchy โ no need to pre-choose k.
A tree showing the merge/split order and the distance at each join.
Single linkage can "chain"; complete linkage makes compact clusters.
No need to fix k in advance; produces a full hierarchy and interpretable tree.
Costly (O(nยฒ) or worse) and merges/splits are irreversible โ a bad early step stays.
Use the elbow method (within-cluster sum of squares) or silhouette score to pick a sensible k for k-means.
Simple, fast and scalable โ great for large, roughly spherical clusters.
Needs k up front, sensitive to initial centroids and outliers, and assumes convex, similar-sized clusters.
Points far from any cluster centre (or in very low-density regions) are flagged as outliers โ useful for fraud and fault detection.
Uses actual data points as centres, making it more robust to outliers than k-means.
Euclidean, Manhattan or cosine โ the choice of similarity shapes the clusters found.
Two clear explainers from StatQuest with Josh Starmer on the two clustering families in this unit.
Videos are embedded from YouTube and belong to their creators. If a frame is blank, your network may block YouTube.