What the K-Means Objective Measures
A clustering is useful only relative to the feature space and criterion used to define it. K-means uses a particular geometric criterion: it seeks groups whose profiles lie close to their group means, with closeness measured by squared Euclidean distance. The objective is therefore a measure of within-cluster variation, not a probability model and not a direct measure of biological similarity.
Suppose \(x_1,\ldots,x_n\) are complete profile vectors in \(\mathbb{R}^p\), where each coordinate is a measured or transformed feature, and let \(K\) be a chosen integer with \(1\leq K\leq n\). All coordinates must be represented in a common Euclidean space. A clustering into \(K\) groups is a partition \(C_1,\ldots,C_K\) of the observations: each observation belongs to exactly one group, and each group is nonempty. The Euclidean squared distance between vectors \(x\) and \(y\) is \(\|x-y\|^2=\sum_{j=1}^{p}(x_j-y_j)^2\).
The objective gives every observation equal weight and squares every coordinate difference. Thus a few large deviations can contribute substantially, and features with large numerical scales can dominate unless the scale is scientifically appropriate or the data have been transformed. In genomic profiles, the coordinates might be normalized expression measurements or other profile features; the objective itself does not decide how those features should be prepared.
Why the Centroid Is the Mean
The centroid is not simply a convenient representative. For squared Euclidean distance, the arithmetic mean is the point that minimizes the total squared distance from the observations in a fixed cluster. This fact explains why the objective uses centroids and is central to its geometry.
To verify the result, write \(x_i-c=(x_i-\bar{x})+(\bar{x}-c)\), square the norm, and sum over the cluster. The cross-term vanishes because the deviations from the mean sum to zero:
The final term is nonnegative and equals zero at \(c=\bar{x}\), proving the claim. For a fixed partition, the best possible representative for each cluster is therefore its centroid. This is a statement about squared Euclidean loss; with a different loss, the best representative can differ.
Worked Example: Finding the Centroid and WCSS
Consider a hypothetical one-feature profile with values \(2,4,6\), all placed in one cluster. The centroid is $$ \bar{x}=\frac{2+4+6}{3}=4. $$ The cluster's WCSS is the sum of squared deviations from that mean: $$ (2-4)^2+(4-4)^2+(6-4)^2=4+0+4=8. $$
To check that \(4\) is the minimizing center rather than merely a plausible summary, let \(c\) be any proposed center. The identity above gives $$ \sum_{i=1}^{3}(x_i-c)^2=8+3(c-4)^2. $$ For example, choosing \(c=5\) gives \(8+3(1)^2=11\), which also follows directly from \((2-5)^2+(4-5)^2+(6-5)^2=9+1+1=11\). This exceeds 8, and every other \(c\neq4\) adds a positive term.
Nearest Centers and Voronoi Geometry
For a fixed set of centers \(c_1,\ldots,c_K\), the squared-distance rule assigns a profile to a closest center. The region of space closest to a given center is its Voronoi region. These regions are separated by boundaries where distances to two or more centers are equal. For distinct centers in ordinary Euclidean space, each pairwise equal-distance locus is a hyperplane, and each Voronoi region is an intersection of the corresponding half-spaces, hence is convex. The shared boundary for a pair of regions may be empty; when nonempty, it is a portion of the corresponding hyperplane.
For two centers \(c_a\) and \(c_b\), equality of squared distances gives a useful boundary equation. Expanding both sides and cancelling \(x^\mathsf{T}x\) yields
This equation describes a hyperplane perpendicular to the line joining the centers. If the centers coincide, their distance comparisons tie everywhere; distinct centers give the usual separating boundary. Importantly, nearest-center assignment is a rule for fixed centers. If some center has no observations assigned to it, the induced assignment is not a partition into \(K\) nonempty clusters; its Voronoi region may nevertheless contain observed profiles tied with another center.
Worked Example: Profile Assignments and a Voronoi Boundary
Suppose four hypothetical profiles have two measured, already prepared coordinates: \(x_1=(1,1)\), \(x_2=(2,1)\), \(x_3=(5,4)\), and \(x_4=(6,4)\). Consider centers \(c_1=(1.5,1)\) and \(c_2=(5.5,4)\). These are the means of the proposed groups \(\{x_1,x_2\}\) and \(\{x_3,x_4\}\), respectively.
The squared distances to \(c_1,c_2\), in that order, are \(0.25,29.25\) for \(x_1\); \(0.25,21.25\) for \(x_2\); \(21.25,0.25\) for \(x_3\); and \(29.25,0.25\) for \(x_4\). For instance, the distance from \(x_2=(2,1)\) to \(c_2=(5.5,4)\) is \((2-5.5)^2+(1-4)^2=12.25+9=21.25\). Thus the nearest-center assignments agree with the proposed groups.
The WCSS for these assignments is the sum of the four within-group squared distances: $$ W=0.25+0.25+0.25+0.25=1.00. $$ The boundary between the centers satisfies \(2x^\mathsf{T}(c_2-c_1)=\|c_2\|^2-\|c_1\|^2\). Here \(c_2-c_1=(4,3)\), \(\|c_2\|^2=46.25\), and \(\|c_1\|^2=3.25\), so the boundary is \(4x_1+3x_2=21.5\). The second profile lies on the \(c_1\) side because \(4(2)+3(1)=11<21.5\); the third lies on the \(c_2\) side because \(4(5)+3(4)=32>21.5\).
Comparing Candidate Partitions
A WCSS value is meaningful only in relation to a specified coordinate system, value of \(K\), and partition. For a fixed data set and \(K\), a lower value is better according to this objective. It does not establish that the groups are biologically real or that the chosen \(K\) is appropriate. In particular, adding groups cannot increase the best attainable WCSS: a group can be split into nonempty subsets, and re-centering those subsets cannot increase the sum of squared distances. This monotonicity means WCSS alone cannot choose \(K\).
Worked Example: Comparing Two Two-Cluster Partitions
Consider hypothetical one-coordinate profiles \(0,2,3,10\) and \(K=2\). For partition A, use clusters \(\{0,2,3\}\) and \(\{10\}\). Their means are \(5/3\) and \(10\). The WCSS is $$ \left(0-\frac{5}{3}\right)^2+ \left(2-\frac{5}{3}\right)^2+ \left(3-\frac{5}{3}\right)^2+(10-10)^2 =\frac{25+1+16}{9}+0=\frac{14}{3}\approx4.667. $$
For partition B, use \(\{0,2\}\) and \(\{3,10\}\), whose means are \(1\) and \(6.5\). Its WCSS is $$ (0-1)^2+(2-1)^2+(3-6.5)^2+(10-6.5)^2 =1+1+12.25+12.25=26.50. $$ Partition A has the smaller WCSS of these two candidates. That comparison does not by itself prove that A is the global minimizer among every possible partition; it establishes only which of these specified candidates better fits the stated criterion.
Assumptions, Diagnostics, and Alternatives
The k-means objective is deterministic: it requires no sampling distribution or independence assumption to be calculated. Its interpretation nevertheless relies on substantive choices. Each observation must have comparable meaning in a common coordinate system, the selected distance must reflect relevant differences, and equal observation weights must be defensible. Squaring makes the criterion especially sensitive to extreme profiles. If one coordinate has a much larger scale or variance than others, it can dominate distances; centering and scaling may address scale differences, but should be chosen based on the scientific meaning of the measurements, not applied mechanically.
The geometry also constrains the kinds of groupings the objective favors. Nearest-centroid regions are convex, and the squared-distance criterion tends to favor compact groups around their means. It can represent awkwardly shaped or strongly overlapping groups poorly. In high dimensions, distance concentration can make pairwise distances less discriminating, so a nearest-center assignment may convey less separation than the low-dimensional picture suggests. A low WCSS is not a guarantee of stable assignments, meaningful separation, or useful biological interpretation.
Useful checks include confirming that the input coordinates and scaling are as intended, inspecting whether a small number of profiles or features dominate the squared deviations, and examining whether assignments depend on a narrow distance margin between competing centers. A profile exactly on a Voronoi boundary is tied; a profile nearly on one may be sensitive to small changes. Also inspect for empty groups when translating centers into assignments. These checks diagnose aspects of the criterion and its geometry; they do not replace a separate assessment of whether the resulting clusters answer the scientific question.
Alternative clustering criteria encode different preferences. A medoid-based criterion uses an observed profile as a representative rather than the coordinate-wise mean, and can be less affected by an extreme profile. Hierarchical methods define groups through a distance-and-linkage rule rather than by minimizing this centroid-based WCSS. Probabilistic mixture models describe profiles through distributions and quantify uncertainty differently. These approaches do not simply provide interchangeable calculations of the same quantity: they answer different modeling or geometric questions. The appropriate choice depends on the profile representation and scientific aim.
Check Your Understanding
Answer each question, then compare your reasoning with the solutions below.
- For a cluster containing the one-dimensional values \(1\) and \(5\), find its centroid and WCSS.
- For centers \(c_1=0\) and \(c_2=4\) on a line, find the Voronoi boundary and describe where the point \(x=3\) is assigned.
- Why does the smallest WCSS among two candidate partitions not establish that either partition is biologically useful?
- State one reason that a large-scale coordinate can dominate the k-means objective and one diagnostic response.
Solutions. (1) The centroid is \((1+5)/2=3\), and WCSS is \((1-3)^2+(5-3)^2=4+4=8\). (2) Equal squared distances satisfy \((x-0)^2=(x-4)^2\), giving \(x=2\). Since \(3\) is closer to \(4\) than to \(0\), it is assigned to \(c_2\). (3) WCSS measures squared distance to centroids for the chosen coordinates and \(K\); it does not establish biological meaning, and the best attainable WCSS cannot increase when \(K\) increases. (4) Squaring coordinate differences allows a feature with a much larger numerical scale to contribute disproportionately. Check coordinate scales and whether the chosen transformation is scientifically justified before interpreting the assignments.