Global Optimal K-Medoids Clustering of One Million Samples

Jiayang Ren, Kaixun Hua, Yankai CaoNeurIPS 2022

Introduction

K-Medoids is a highly interpretable clustering algorithm similar to K-Means, but with a strict constraint: the cluster centers (medoids) must be actual data points from the dataset. This allows for arbitrary dissimilarity metrics and robust outlier handling, but it also makes the problem notoriously NP-hard.

Historically, researchers have relied on heuristic methods (like PAM or CLARA) to find "good enough" solutions, but these offer no guarantees of finding the global optimum. Conversely, exact deterministic solvers—such as standard Branch and Bound (BB) or commercial solvers like CPLEX—scale terribly. Because they branch on binary variables representing the assignment of every single sample to a cluster, computational complexity explodes as the dataset grows. Prior to this work, exact solvers maxed out at around 2,000 to 3,000 samples before running out of memory or time.

This paper introduces a highly scalable, deterministic global optimization algorithm that shatters previous limits. By combining a reduced-space branch-and-bound scheme with a tailored Lagrangian relaxation technique, the authors successfully find provably optimal solutions for datasets containing up to one million samples—a staggering 400x improvement over previous state-of-the-art exact solvers.

Methodology: Breaking the Scaling Bottleneck

To break through the traditional scaling bottleneck, the authors completely rethought the search space and bounding strategies.

Reduced-Space Branch and Bound

The "aha" moment of the paper is the decoupling of the search space from the dataset size. Instead of branching on the binary assignment variables for every data point, the algorithm branches only on the continuous bounding regions of the medoids themselves. Because the dimension of the medoids is independent of the number of samples, the depth of the search tree is drastically reduced.

Illustration of bounding regions and distance calculations for medoids.

Tailored Lagrangian Relaxation

To find a tight lower bound at each node in the BB tree, the authors resurrected and adapted a Lagrangian relaxation method from the 1970s. By relaxing the constraint that every sample must belong to exactly one cluster, they achieve a lower bound with a closed-form solution that can be computed analytically and parallelized easily. Uniquely, this method guarantees a maximum duality gap of $1/e$ at the root node.

Bound Tightening and Parallelization

The authors deploy "Probing" and "Feasibility Based Bound Tightening" (FBBT). These techniques dynamically shrink the search space by mathematically proving that certain samples must belong to specific clusters based on current bounds, pruning dead-end branches early.

Furthermore, storing a pairwise distance matrix for millions of samples is impossible on standard hardware ($O(S^2)$ space complexity). To solve this memory crisis, the algorithm distributes the calculation of distance contributions across multiple CPU cores using MPI, computing distances on-the-fly.

Key Results and Performance

The authors evaluated their algorithm on 28 datasets, including 25 real-world datasets from the UCI Machine Learning Repository, a TSP dataset, a chemical engineering dataset, and massive synthetic datasets.

Computational results comparing the proposed BB+LD method against heuristics and CPLEX across various datasets.
  • Beating Commercial Solvers: As shown in the performance tables, the industry-standard solver CPLEX ran out of memory or timed out at the root node for datasets larger than 2,392 samples. The proposed method (BB+LD) handled these with ease, consistently reaching optimality gaps of $\le 0.1\%$.
  • Massive Scale: The algorithm successfully solved the RETAIL-II dataset (1,046,910 samples) to a global optimal gap of $\le 0.1\%$ in under one hour using a parallel computing cluster.
  • Pushing the Limit: On the largest dataset tested (USC1990 with ~2.45 million samples and 68 features), the algorithm achieved a 6.33% optimality gap within the 4-hour time limit, proving it can make meaningful progress on massive, high-dimensional data.

Limitations and Future Directions

While groundbreaking, the approach does have limitations. Even with parallelization, the time complexity of a single Lagrangian Dual iteration scales quadratically with the number of samples ($O(S^2)$). Additionally, while computing distances on-the-fly solves the memory crisis for datasets exceeding 100,000 samples, it introduces a noticeable computational bottleneck compared to using precomputed distance matrices.

Ultimately, having a true global optimal solver finally allows researchers to fairly evaluate and benchmark the accuracy of faster heuristic methods. This baseline is expected to spur the development of much more efficient and accurate approximation algorithms in the future.

Summary updated

BibTeX
@inproceedings{ren2022global,
  author = {Jiayang Ren and Kaixun Hua and Yankai Cao},
  title = {{Global Optimal K-Medoids Clustering of One Million Samples}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2022},
  url = {https://openreview.net/forum?id=SrwrRP3yfq8},
}
Figure