Course map
Stage 1: Foundations
Stage 2: Machine Learning
Stage 3: Deep Learning
Stage 4: LLMs & Generative AI
Stage 5: Production & Specialization

Part 07 / Topic 1 of 5

Clustering with k-means

k-means groups rows into k clusters: place k centres, assign every point to its nearest centre, move each centre to its points' mean, repeat until stable. No labels anywhere — the structure comes from distances alone.

Its assumptions matter: clusters are roughly round, similar in size, and distance means something. That last one is the practical trap — k-means uses Euclidean distance, so a feature ranging in the thousands swamps one ranging in units. Standardize first (the Part 1 one-liner), every time.

Real-world example: group customers by behaviour (tenure, spend, support calls) into segments marketing can name — this part's mini-project.

🧪 Quick quiz

  1. Why scale features before k-means?
Show the answer

k-means uses Euclidean distance, so distances are dominated by features with large ranges — a column measured in thousands would decide every cluster by itself.

Done here? The practice set for Part 7 — 4 exercises with solutions — is on the part page.

Search the guide