English

A New Rejection Sampling Approach to $k$-$\mathtt{means}$++ With Improved Trade-Offs

Data Structures and Algorithms 2025-02-05 v1 Machine Learning

Abstract

The kk-means\mathtt{means}++ seeding algorithm (Arthur & Vassilvitskii, 2007) is widely used in practice for the kk-means clustering problem where the goal is to cluster a dataset XRd\mathcal{X} \subset \mathbb{R} ^d into kk clusters. The popularity of this algorithm is due to its simplicity and provable guarantee of being O(logk)O(\log k) competitive with the optimal solution in expectation. However, its running time is O(Xkd)O(|\mathcal{X}|kd), making it expensive for large datasets. In this work, we present a simple and effective rejection sampling based approach for speeding up kk-means\mathtt{means}++. Our first method runs in time O~(nnz(X)+βk2d)\tilde{O}(\mathtt{nnz} (\mathcal{X}) + \beta k^2d) while still being O(logk)O(\log k ) competitive in expectation. Here, β\beta is a parameter which is the ratio of the variance of the dataset to the optimal kk-means\mathtt{means} cost in expectation and O~\tilde{O} hides logarithmic factors in kk and X|\mathcal{X}|. Our second method presents a new trade-off between computational cost and solution quality. It incurs an additional scale-invariant factor of kΩ(m/β)Var(X) k^{-\Omega( m/\beta)} \operatorname{Var} (\mathcal{X}) in addition to the O(logk)O(\log k) guarantee of kk-means\mathtt{means}++ improving upon a result of (Bachem et al, 2016a) who get an additional factor of m1Var(X)m^{-1}\operatorname{Var}(\mathcal{X}) while still running in time O~(nnz(X)+mk2d)\tilde{O}(\mathtt{nnz}(\mathcal{X}) + mk^2d). We perform extensive empirical evaluations to validate our theoretical results and to show the effectiveness of our approach on real datasets.

Keywords

Cite

@article{arxiv.2502.02085,
  title  = {A New Rejection Sampling Approach to $k$-$\mathtt{means}$++ With Improved Trade-Offs},
  author = {Poojan Shah and Shashwat Agrawal and Ragesh Jaiswal},
  journal= {arXiv preprint arXiv:2502.02085},
  year   = {2025}
}