SESK: Stuff Everyone Should Know · sesk.info/ai-kmeans-needs-k
What must you tell the k-means algorithm before it starts?
The number of clusters, k.
- The correct label for each point
- The number of clusters to make ✔
- The exact coordinates of every centroid
Why: k-means needs k up front. It then places k centroids, assigns each point to the nearest one, moves each centroid to the middle of its points, and repeats.
Huh, didn't know that: It minimizes inertia, the within-cluster sum of squared distances to each centroid.
I asked k-means to organize my sock drawer. It wanted to know how many piles first.
Like this card?
References
Answer: The number of clusters to make. k-means needs k up front. It then places k centroids, assigns each point to the nearest one, moves each centroid to the middle of its points, and repeats.
- scikit-learn User Guide: Clustering scikit-learn.org/stable/modules/clustering.html
This algorithm requires the number of clusters to be specified.
Checked 2026-10-10.
Think this answer is wrong? Tap "Challenge this answer" on the card in the game and tell us why.
More stuff everyone should know
That's stuff everyone should know.