The one idea: K-Means sorts points into K groups by repeating two moves — assign each point to its nearest center, then move each center to the average of the points assigned to it — until nothing changes. It's fast and simple, but it can only draw round, similarly-sized territories, so it will confidently misdraw any cluster shaped like a moon, a ring, or a stretched blob.
⚠️ The trap: The algorithm found 3 clean customer segments, so those segments must be real groups in the data. That feels right and it's wrong. K-Means always returns exactly the K groups you asked for, and it always draws them as round, evenly-sized territories — it will slice a single crescent-shaped cluster clean in half rather than admit it isn't a blob, so a clean-looking result tells you the algorithm converged, not that the shape it drew matches the data.
K-Means is the clustering algorithm most people mean when they say "just cluster it." You hand it a table of numeric features and a number K, and it hands back a label — 0 through K-1 — for every row. No target column, no right answer to check against; it just groups similar rows together. The classic business use is customer segmentation: take income and spending behavior, ask for 5 groups, and get back something you can name and market to. The mechanics are genuinely simple. The judgment — how many groups, whether the shapes it finds are the shapes that are actually there — is where the real skill lives.
The algorithm: two moves, repeated (Lloyd's algorithm)
K-Means (formally, Lloyd's algorithm) does exactly two things…
Keep reading: K Means Clustering
Unlock the full Machine Learning track — every lesson, the AI tutor, and full mock assessments.
- Full lesson content
- AI tutor for this section
- Practice questions