Robust K-means Clustering

Statistics
Introduced by
Cuesta-Albertos, Gordaliza & Matrán
Year
1997
Type
Robust partitional clustering
Family
Multivariate analysis

What does it do?

Robust K-means (trimmed k-means) is a variant of k-means clustering that limits how far outliers and contaminated observations can pull the cluster centers.

It seeks k centers and a set of retained observations, leaving out a user-specified fraction α of the data, so that the retained observations are as close as possible to their nearest centers. In practice an iterative procedure sets aside the observations furthest from their assigned centers and recomputes the centers from the rest. The result is a partition of the bulk of the data, with the trimmed observations reported separately as candidate outliers.

The intuition behind the method

Standard k-means places each cluster center at the mean of its members, so a few extreme points can drag a center away from the group it is meant to describe. Robust K-means changes the criterion: the data themselves decide which observations to leave out ("impartial trimming"), namely those that fit the solution worst. Computationally, a common heuristic ranks observations by their distance to the center they are currently assigned to and sets aside the top α fraction. Those observations take no part in recomputing the centers for that iteration and are reported as potential outliers. Because the trimmed points no longer influence the centers, the centers track the dense core of the data.

History

Cuesta-Albertos, Gordaliza and Matrán (1997), in The Annals of Statistics, studied trimmed k-means as a way to robustify k-means quantizers. Their abstract describes a class of procedures based on impartial trimming, in which the trimmed part is determined by the data, and reports strong consistency results and an assessment of anomaly detection on simulated data. García-Escudero, Gordaliza, Matrán and Mayo-Iscar (2008) introduced a general trimming approach that allows clusters with different scatters and weights, with restrictions on the ratio of the largest to smallest eigenvalues of the group scatter matrices.

When to use it

Use Robust K-means when your data are continuous multivariate measurements, you suspect some contamination or outlying records, and you can specify the number of clusters k in advance. It suits settings where the main departure from standard k-means is contamination rather than strongly non-spherical clusters. Choose α from your judgement of the contamination rate; a value such as 0.05 is a common illustrative starting point, not a prescribed default, and it is worth checking how the solution changes over a range of α values. The trimming step does not select k, so k must be chosen separately (see the FAQ). Avoid it when clusters differ markedly in density, size or elliptical shape, where Gaussian mixture, robust mixture models or TCLUST may be more appropriate. Be cautious when contamination is large or uncertain, since heavy trimming can remove genuine cluster members.

Limitations and considerations

  • The number of clusters k must be specified in advance, as in standard k-means.
  • The trimming proportion α must also be chosen by the analyst. If it is too small, outliers remain influential; if it is too large, legitimate members of clusters are trimmed.
  • Inherits the spherical-cluster assumption of standard k-means (Euclidean distance and mean centers), so elongated clusters or clusters of very different sizes may not be recovered well.
  • A small but genuine cluster lying far from the others can be trimmed as if it were outlying, particularly when k is set too low.
  • Multiple random starts are needed to reduce sensitivity to initialization, which increases computation time.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Limits the pull of outliers on cluster centers through an explicit trimming fraction that the analyst controls.
  • Each iteration keeps the assign-and-update structure of standard k-means, with one additional ranking step to identify the trimmed observations.
  • Flags suspect observations as a by-product of fitting, which supports data-quality review.
  • Uses a single additional parameter, α, whose meaning is direct: the share of observations allowed to be trimmed.
  • The original trimmed k-means work establishes strong consistency under general conditions and includes a study of anomaly detection in simulated data.

Applications

  • Customer segmentation on continuous transaction measures, where erroneous or fraudulent records could otherwise pull segment centers toward themselves.
  • Clustering of sensor-derived or image-derived features, where corrupted measurements form a small set of extreme points among otherwise homogeneous groups.
  • Biomedical measurement profiles in which a few contaminated or mislabelled samples are suspected, with flagged samples reviewed separately.
  • Environmental monitoring of continuous readings, grouping stations into regimes while isolating anomalous readings for inspection.
  • Survey-based continuous scales, where careless responses could distort attitude-group centers; flagged cases can be checked against response patterns.

How it works

How it works

1

Choose k, the number of clusters, and α, the trimming proportion, based on domain knowledge about the likely contamination rate. Initialize the k cluster centers, either at random or with a seeding strategy such as k-means++. The procedure below is an alternating heuristic that approximates the trimmed k-means criterion: minimize the sum of squared distances of the retained observations (about n − ⌊αn⌋ of them) to their nearest of k centers, over the choice of centers and of the trimmed subset.

Formula
\mu_1^{(0)},\dots,\mu_k^{(0)};\quad m=n-\lfloor \alpha n\rfloor \text{ retained points}
2

Compute the squared Euclidean distance from every observation to each of the k current centers, and tentatively assign each observation to its nearest center.

Formula
d_{ij}=\lVert x_i-\mu_j\rVert^2,\qquad c_i=\arg\min_j d_{ij}
3

Rank all observations by the distance to their assigned center and flag the ⌈αn⌉ observations with the largest distances as trimmed. Trimmed observations are excluded from the center update in this iteration. This is the data-determined trimming of the impartial-trimming framework, applied here for the current centers.

Formula
T=\text{indices of the } \lceil\alpha n\rceil \text{ largest values of } \min_j d_{ij}
4

Recompute each cluster center as the mean of only the untrimmed observations assigned to that cluster. This mirrors the update step of standard k-means but leaves out the flagged observations, so they cannot pull the centers.

Formula
\mu_j=\frac{1}{|\{i\notin T:c_i=j\}|}\sum_{i\notin T,\,c_i=j}x_i
5

Repeat the assign, trim, and update steps until cluster assignments and trimmed sets no longer change between iterations, or a maximum iteration count is reached. Each pass does not increase the trimmed criterion, but the procedure may reach a local optimum, so use several starts. Report the final k centers, the cluster memberships of retained observations, and the identities of the trimmed observations.

Formula
\min_{\mu,\,T}\sum_{i\notin T}\min_j\lVert x_i-\mu_j\rVert^2;\ \text{stop when } c \text{ and } T \text{ are unchanged or max iterations reached}

Common pitfalls

  • Setting α = 0 defeats the purpose of the robust variant — if no trimming is wanted, use standard k-means.
  • Interpreting trimmed observations automatically as data-entry errors rather than scientifically meaningful extreme cases; always inspect the trimmed set before discarding those records.
  • Choosing k based on within-cluster sum of squares from a standard k-means run, then applying robust k-means with the same k — the outliers can inflate standard k-means clusters and distort the elbow or silhouette criterion.
  • Applying robust k-means to binary or ordinal data without adapting the distance metric — the Euclidean distance and mean update are only natural for continuous measurements.

Frequently asked questions

How do I choose the trimming proportion α?

Set α from domain knowledge about how much contamination is plausible. A value such as 0.05 is a common illustrative starting point, not a rule. Explore sensitivity by running the algorithm with several values (e.g., 0.00, 0.05, 0.10, 0.15) and checking whether the cluster centers and assignments change substantially. Stable results across a range of α values suggest that the solution is not artificially forced by the trimming level.

How do I choose k, and how do I read the output?

Trimming does not select k. Fit the model over a range of k values with the same α, and compare the trimmed within-cluster sum of squares and the stability of the clusters across starts; avoid relying on an elbow taken from a non-robust k-means run. To read the output, inspect the final centers, the sizes of the clusters, and the trimmed set. If trimmed observations are concentrated together, they may form a small genuine cluster, which suggests increasing k. Compare results across α to see which observations are consistently trimmed.

Are trimmed observations automatically outliers I should delete?

No. Trimmed observations are simply those farthest from any cluster center given the current solution. They may be genuine outliers, data errors, or members of small clusters not captured by the chosen k. Always examine them before deciding whether to exclude them from downstream analyses.

How does robust k-means differ from TCLUST?

Robust k-means (trimmed k-means) uses Euclidean distance and spherical cluster centers, making it a direct robust analogue of standard k-means. TCLUST generalizes the trimming idea to allow each cluster to have its own scatter matrix and weight, with restrictions on the ratio between the largest and smallest eigenvalues of those matrices, making it suitable when clusters differ in shape and volume. Robust k-means has fewer parameters; TCLUST is more flexible but requires additional tuning of the eigenvalue-ratio constraint.

Do I still need multiple random starts?

Yes. Like standard k-means, robust k-means can converge to local optima. Running the algorithm from many random initializations (or using a k-means++ seeding strategy) and selecting the run with the lowest trimmed within-cluster sum of squares is strongly recommended.

Can robust k-means handle non-Euclidean data?

The standard algorithm uses Euclidean distance and arithmetic means; it is designed for continuous, roughly interval-scaled variables. For binary, ordinal, or mixed-type data the distance metric and center-update rule would need to be adapted (e.g., using k-medoids with a suitable dissimilarity measure), which moves beyond the standard robust k-means framework.

Related methods

Sources

  1. Cuesta-Albertos, J. A., Gordaliza, A., & Matrán, C. (1997). Trimmed k-means: An attempt to robustify quantizers. The Annals of Statistics, 25(2), 553–576.

    Open DOI reference
  2. García-Escudero, L. A., Gordaliza, A., Matrán, C., & Mayo-Iscar, A. (2008). A general trimming approach to robust cluster analysis. The Annals of Statistics, 36(3), 1324–1345.

    Open DOI reference