k-Means Clustering Assumptions
A common first impression of k-means is that it is a general-purpose grouping tool.
The Unstated Belief About Choosing k
A common first impression of k-means is that it is a general-purpose grouping tool. You choose a number of clusters, the algorithm runs, and out come groups. Many learners carry an unstated assumption with them: if the number of clusters is right, k-means will recover the groups that are really present in the data. This article tests that assumption. The short answer is that k-means can miss the groups even when the number of clusters is correct, because the shape of its answer is fixed by how it measures distance to centers.
What do you think happens?
Suppose two interleaved half-moons are the true groups, and you set k = 2, which is the correct number. Will k-means return the two half-moons as its two clusters?
Reveal answer
No. k-means cannot recover the two half-moon shapes, even with k = 2.
The number of clusters is correct, so the failure has nothing to do with choosing k. The shape of k-means output is limited by its convex, center-based regions, and two interleaved half-moons do not fit those regions.
Why the Right k Is Not Enough
The number k tells k-means how many groups to produce. It does not tell the algorithm what shape those groups must have. Recovering the true groups requires that the regions k-means draws line up with the regions the data actually occupies. Those two things are separate. A correct k can still produce a wrong partition, because the partition is determined by the algorithm's built-in assumptions about cluster shape and size, not by the count alone.
Convex Regions from Nearest-Center Assignment
A convex region is one in which, for any two of its points, the straight line between them also stays inside the region. A cluster is convex in this sense if you could fill it by drawing straight lines between any two of its points.
k-means defines each cluster solely by its center. Each point is assigned by its distance to the nearest center. Because of this rule, the region belonging to each cluster is convex. The algorithm can only capture relatively simple shapes, since every cluster is effectively a region around one center. The diagram below shows the structure: two centers, and the boundary that falls between them.
The Midpoint Boundary and Equal Diameter
The second assumption concerns size. k-means treats all clusters as having the same diameter in some sense. It always places the boundary between two clusters exactly in the middle between their centers. The midpoint rule is the direct consequence of nearest-center assignment: a point on the midpoint is equally far from both centers, so the boundary falls there.
That single rule explains many surprising results. If one cluster is tight and another is spread out, the midpoint boundary can cut through the spread-out cluster, even though the points near that boundary really belong to it. The algorithm does not look at how far a cluster extends. It only looks at where the center sits.
The boundary depends only on the two centers. Two clusters with identical centers placed the same way will always produce the same midpoint, regardless of how many points each cluster contains or how far its points spread.
Tracing a Boundary Step by Step
Following a point across the midpoint
Cluster A has its center at position 0 on a line, and Cluster B has its center at position 4. Cluster A's points spread widely to the right. Where is the boundary, and which cluster gets a point at position 2.5?
- 1Locate the two centers
Center A is at 0 and Center B is at 4. Only these two positions matter for the assignment rule.
- 2Find the midpoint
The midpoint between 0 and 4 is 2. The boundary sits exactly there, following the midpoint rule.
- 3Compare the point to the boundary
The point at 2.5 lies to the right of the boundary at 2, so it is closer to Center B at 4 than to Center A at 0.
- 4Interpret against the true groups
If Cluster A's spread naturally reaches 2.5, the point truly belongs to A, but k-means assigns it to B. This is the midpoint rule cutting through a spread-out cluster.
The boundary is at 2, and the point at 2.5 is assigned to Cluster B even though its true group may be A. The center positions alone decided the assignment.
Dense and Sparse Neighbors
The first failure case involves clusters that differ in density. Imagine a dense region in the lower left, a dense region in the upper right, and a sparser region in the center. A human looking at this picture would likely name these three groups: the dense lower-left region as the first cluster, the dense upper-right region as the second, and the less dense central region as the third.
The source reports what happens when k-means is run on this kind of data. Cluster 0 and cluster 1 both contain some points that are far away from the other points in their own cluster and that reach toward the center of the plot. The algorithm has pulled the edges of the dense regions into neighboring clusters. The midpoint rule places the boundary between centers, and a sparse cluster's points that drift toward the middle get assigned to a neighbor whose center happens to be closer.
Stretched Clusters Along a Diagonal
The second failure involves clusters that are not round. k-means also assumes that all directions are equally important for each cluster. Picture a dataset with three clearly separated parts, where each part is stretched along a diagonal rather than being a circle. The groups remain easy to see, but the stretching means that a point along the long axis of one group can be closer to the center of a neighboring group than to its own group's center.
The source states the reason plainly: k-means only considers the distance to the nearest cluster center, and it cannot handle this kind of data. A stretched group has no single center that represents all of its directions equally. The algorithm sees one center and one distance, so it cannot represent a group that extends far in one direction and little in another.
Two Interleaved Half-Moons
The third failure involves clusters with complex shapes. The source uses a two-moons dataset in which two interleaved half-circles form two groups. Visually, the correct answer is obvious: each half-moon is one cluster. Here we would hope that the clustering algorithm can discover the two half-moon shapes, but this is not possible using the k-means algorithm.
Because each cluster is convex and separated by a straight midpoint boundary, k-means cuts across the moons instead of separating them. The number of clusters is correct, so the failure has nothing to do with choosing k. The comparison below sets the expected grouping beside the grouping k-means produces.
Mistakes Beginners Make
Common mistake Assuming a correct k guarantees the true groups
What it looks likeSetting k = 2 for two interleaved half-moons and expecting two moon-shaped clusters.
Why it failsk controls only how many clusters are produced. The shape of the answer is fixed by convex, center-based regions.
Do this insteadCheck whether the true groups are roughly round, similarly sized, and similarly dense before trusting the result.
Common mistake Reading the midpoint boundary as a sign of the true edge
What it looks likeA spread-out cluster next to a tight one loses its outer points to the tight neighbor.
Why it failsThe boundary is placed exactly midway between centers, not where the data actually changes.
Do this insteadCompare the boundary against the spread of each cluster, not only against the centers.
Common mistake Treating all directions as equally informative
What it looks likeThree diagonally stretched groups are cut by a point that lies along one group's long axis.
Why it failsk-means represents each cluster with one center and one distance, so it cannot represent extension in one direction.
Common mistake Believing that visual separation in a plot implies k-means will separate the same groups
Locating Where Predictions Diverge
When a clustering result looks wrong, the useful question is where it departs from what you expected. A reliable way to find that spot is to plot the predicted labels against the structure you believe is in the data, then check each region in turn. Start with the region that looks most mismatched.
- 1Plot the points colored by predicted label, and beside them plot the structure you expect, colored by true group.
- 2Pick the region where the two colorings disagree most clearly.
- 3For a point in that region, check how close it is to its assigned center.
- 4Check whether a neighboring center is nearly as close. If it is, the midpoint boundary is the likely cause.
- 5Repeat for the next mismatched region, noting whether the pattern matches density, stretch, or shape.
In the varying-density case, the mismatch sits along the edges of the dense regions, where far-reaching points get pulled into a neighbor. That location is the diagnostic clue: the divergence concentrates where the midpoint boundary crosses a region that extends further than its center suggests.
A clustering run with k = 3 on three diagonally stretched groups assigns a few points at the far ends of two groups to the wrong neighbor. Describe, in your own words, which points you would check first, and what two quantities you would compare for each one.
Hints
- Start from the region that looks most mismatched, not from the whole plot.
- Compare distance to the assigned center with distance to the nearest neighboring center.
- Think about which direction the stretch extends, since a point on the long axis can be closer to a foreign center.
Checking a Mismatch Against Three Failure Patterns
Look at a clustering result where one tight cluster sits beside a spread-out cluster, and the spread-out cluster's outer points are assigned to the tight neighbor. Which of the three failure situations does this most closely match, and which assumption explains the boundary placement?
Hints
- Ask whether the trouble comes from different densities, stretched shapes, or complex shapes.
- Think about where the midpoint between the two centers falls.
Key Takeaways
- A correct number of clusters controls how many groups k-means produces, but not whether those groups match the true structure.
- k-means assigns each point to its nearest center, so each cluster is a convex region, and the boundary between two clusters falls exactly midway between their centers.
- Varying density, stretched or non-spherical clusters, and complex shapes such as two interleaved half-moons can each produce results that diverge from the expected groups.
- To locate a divergence, compare predicted labels with the expected structure, start with the most mismatched region, and check distances to the assigned center and the nearest neighboring center.