The Exact Approximation Ratio of $k$-means++
Aravind Reddy
cs.DS
Nov 9, 2026 · v3
cs.LG
TL;DR
The exact approximation ratio of k-means++, including exact-rational certificates and an independent specification of the seeding process, is formally verified in Lean 4; the formalization ships as ancillary files.
Abstract
The $k$-means++ algorithm is the standard initialization for $k$-means clustering, one of the most widely used methods in machine learning and data analysis, adopted both for its empirical performance and its worst-case approximation guarantee. Given a finite Euclidean point set, $k$-means seeks $k$ centers minimizing the sum of squared distances from each point to its nearest center. $k$-means++ picks the first center uniformly at random from the points and each subsequent center with probability proportional to its squared distance to the nearest chosen center. Let $R_k$ be the smallest factor such that, on every input, the expected cost of these $k$ centers is at most $R_k$ times the optimal cost. In their seminal paper introducing $k$-means++, Arthur and Vassilvitskii (SODA 2007) showed that $2\ln k \le R_k \le 8(\ln k + 2)$, and Makarychev, Reddy and Shan (NeurIPS 2020) lowered the upper bound to $5(\ln k + 2)$. We determine $R_k$ exactly for all $k$ and discover a striking phase transition. For $k \ge 19$, $R_k = 2H_{k-1} + 2,$ where $H_j = 1 + \frac12 + \frac13 + \dots + \frac1j$ is the $j$th harmonic number. For $2 \le k \le 18$, $R_k$ is the maximum of an explicit rational function of one variable and strictly exceeds $2H_{k-1} + 2$, with $R_2 = 5$ and $R_3 = 185/32$. In particular, $2\ln k + 2 \le R_k \le 2\ln k + 4$ for every $k \ge 1$. When a cluster is first sampled, previous analyses bound its expected cost by a constant times its optimal cost and charge that cost for the rest of the run. We instead track what happens to a cluster after its first hit. At each later draw, the probability of sampling that cluster equals its share of the total cost. A poor first choice can therefore make a second hit more likely, and that second hit can bring the cluster's cost back down. The full result is formally verified in Lean 4, and the formalization is included as ancillary files.
Problem
The worst-case approximation ratio R_k of k-means++ seeding was previously known only within constant factors: 2 ln k ≤ R_k ≤ 5(ln k + 2). The goal is to determine R_k exactly for every k.
Approach
Instead of charging a cluster's cost from its first hit onward, the analysis tracks each cluster after that hit. A later second hit, which a poor first choice makes more likely, can bring the cluster's cost back down. Matching lower bounds come from two extremal inputs, a hub with a rare outlier and a reservoir, analysed via exact finite recurrences. The upper bound combines a potential-function (restoration) argument, harmonic-clock charges, a race analysis and a Euclidean reset bound, and the whole result is verified in Lean 4.
Results
R_k = 2H_{k-1}+2 for k ≥ 19. For 2 ≤ k ≤ 18, R_k equals the maximum J_k of an explicit one-variable rational function, with R_2 = 5 and R_3 = 185/32. As a consequence, 2 ln k + 2 ≤ R_k ≤ 2 ln k + 4 for all k.
| k | J_k | 2H_{k-1}+2 | R_k |
|---|
| 2 | 5 | 4 | 5 |
| 3 | 5.78125 | 5 | 5.78125 |
| 18 | 8.8912 | 8.8791 | 8.8912 |
| 19 | 8.9823 | 8.9902 | 8.9902 |
| 20 | 9.0688 | 9.0955 | 9.0955 |
Exact approximation ratio R_k for selected k (excerpt)