Skip to content

AI Glossary · Concepts

What is K-means clustering?

K-means clustering

K-means clustering splits unlabeled data into a chosen number of groups, k, by repeatedly assigning each point to its nearest group center and then moving each center to the average of its assigned points.

Also known as: k-means

· Chain of Thought

Model Training

  • 1 episode
  • 1 source

A delivery company wants to split 10,000 addresses into eight driver zones. K-means starts by dropping eight centers onto the map, often at randomly chosen addresses. Each address joins its nearest center. Each center then moves to the middle of its addresses. Repeat assign-and-move until the centers stop shifting, and the result is eight compact zones.

It is one of the oldest and simplest cluster analysis methods, simple enough that people reinvent it. In episode 41 at 5:52, the narrator explains that Writer’s Melisa Russak built something that turned out to be essentially k-means clustering in her first data science job, before she learned the algorithm had existed for decades. Galileo sponsored Season 2, including episode 41; the episode has no separate sponsor read in its transcript.

K-means has known weak spots. You must choose k up front, and different starting centers can produce different groups, so tools run it several times and keep the best result. It assumes roughly round, similar-sized groups and struggles with long, thin or uneven ones. Columns on bigger scales dominate the distance, so features usually need scaling first. The groups it finds are not proof of real categories; check that they are useful. Despite the similar name, k-nearest neighbors is a different method that predicts labels from labeled examples.

Sources

  • scikit-learn: Clustering, K-means — Describes Lloyd's algorithm (choose initial centroids, assign samples to the nearest centroid, recompute centroids as means, repeat), its need for a specified number of clusters, its assumption of convex, isotropic clusters and its dependence on initialization; checked October 24, 2026.

Go deeper

From the conversation