[Paper Review] BanditPAM: Almost Linear Time $k$-Medoids Clustering via Multi-Armed Bandits
BanditPAM is a randomized algorithm that accelerates $k$-medoids clustering by reducing the computational complexity of each PAM iteration from $O(n^2)$ to $O(n\log n)$ using multi-armed bandit techniques. It achieves state-of-the-art clustering quality while performing up to 200x fewer distance computations and running up to 4x faster than baseline methods on large real-world datasets.
Clustering is a ubiquitous task in data science. Compared to the commonly used $k$-means clustering, $k$-medoids clustering requires the cluster centers to be actual data points and support arbitrary distance metrics, which permits greater interpretability and the clustering of structured objects. Current state-of-the-art $k$-medoids clustering algorithms, such as Partitioning Around Medoids (PAM), are iterative and are quadratic in the dataset size $n$ for each iteration, being prohibitively expensive for large datasets. We propose BanditPAM, a randomized algorithm inspired by techniques from multi-armed bandits, that reduces the complexity of each PAM iteration from $O(n^2)$ to $O(n \\log n)$ and returns the same results with high probability, under assumptions on the data that often hold in practice. As such, BanditPAM matches state-of-the-art clustering loss while reaching solutions much faster. We empirically validate our results on several large real-world datasets, including a coding exercise submissions dataset, the 10x Genomics 68k PBMC single-cell RNA sequencing dataset, and the MNIST handwritten digits dataset. In these experiments, we observe that BanditPAM returns the same results as state-of-the-art PAM-like algorithms up to 4x faster while performing up to 200x fewer distance computations. The improvements demonstrated by BanditPAM enable $k$-medoids clustering on a wide range of applications, including identifying cell types in large-scale single-cell data and providing scalable feedback for students learning computer science online. We also release highly optimized Python and C++ implementations of our algorithm.
Motivation & Objective
- Address the high computational cost of $k$-medoids clustering, particularly the $O(n^2)$ complexity per iteration in state-of-the-art algorithms like PAM and FastPAM1.
- Overcome the limitations of $k$-means clustering, such as non-interpretability of cluster centers and incompatibility with arbitrary distance metrics.
- Enable scalable $k$-medoids clustering on large datasets—such as single-cell RNA-seq and online education data—where prior methods are prohibitively slow.
- Maintain clustering quality equivalent to PAM while drastically reducing runtime and distance evaluations through bandit-based sampling strategies.
Proposed method
- Adapt multi-armed bandit algorithms to the $k$-medoids problem, specifically targeting the SWAP step of PAM where medoid swaps are evaluated.
- Use upper confidence bound (UCB) bandit strategies to sample and estimate the loss reduction of potential medoid swaps with high probability.
- Estimate sub-Gaussian parameters adaptively for each candidate medoid and target point to ensure confidence bounds on loss estimates.
- Apply a two-phase approach: first, use bandit sampling to identify high-reward swaps efficiently; second, validate top candidates with full distance computation.
- Leverage the fact that distance computation dominates runtime, making the number of distance evaluations a key proxy for algorithmic complexity.
- Integrate the bandit framework into the PAM SWAP phase, replacing exhaustive $O(kn^2)$ comparisons with $O(n\log n)$ expected evaluations under mild data assumptions.
Experimental results
Research questions
- RQ1Can multi-armed bandit techniques be effectively applied to reduce the computational cost of the $k$-medoids SWAP step without sacrificing clustering quality?
- RQ2Does the proposed bandit-based sampling strategy scale sub-quadratically with dataset size $n$, achieving $O(n\log n)$ complexity in practice?
- RQ3To what extent can the number of distance evaluations be reduced while maintaining the same final medoid assignments as PAM?
- RQ4How do the empirical distributions of loss estimates and arm parameters support the theoretical assumptions of sub-Gaussianity and distributional modeling?
- RQ5Can BanditPAM achieve comparable or better clustering performance than PAM and FastPAM1 on real-world datasets with diverse data types and distance metrics?
Key findings
- BanditPAM reduces the number of distance evaluations per iteration to $O(n\log n)$, with a measured slope of 1.046 on a log-log plot, confirming near-linear scaling.
- On the 10x Genomics 68k PBMC dataset, BanditPAM performed up to 200x fewer distance computations than PAM while achieving identical clustering results.
- In experiments on Code.org’s HOC4 dataset, BanditPAM achieved the same medoid assignments as PAM but ran up to 4x faster.
- The empirical distribution of loss estimates and true arm parameters closely matched sub-Gaussian assumptions, validating the theoretical modeling choices.
- BanditPAM matched or exceeded the clustering quality of FastPAM1 and PAM while significantly outperforming them in runtime and distance evaluation efficiency.
- The algorithm’s performance was robust across diverse data types, including single-cell RNA-seq, handwritten digits (MNIST), and tree-structured code submissions.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.