K*-Means: A Parameter-free Clustering Algorithm

Louis Mahon, Mirella Lapata · DOI

Abstract

Clustering is a fundamental task in machine learning, yet most existing algorithms require users to pre-specify critical parameters, such as the number of clusters ($k$) in $k$-means or neighborhood density in DBSCAN. This paper presents K-Means, a novel, parameter-free clustering algorithm that leverages the Minimum Description Length (MDL) principle. By framing clustering as a data compression problem, K-Means automatically identifies the optimal number of clusters by balancing model complexity against data fit. Our evaluation across synthetic, image, audio, and text datasets demonstrates that K*-Means accurately recovers the true cluster count with high efficiency, often outperforming established baselines like X-Means and HDBSCAN.

Introduction: The Parameter Problem in Clustering

Despite its ubiquity, clustering remains a largely manual process. The standard $k$-means algorithm requires a pre-defined $k$, and selecting an incorrect value leads to poor data representation. While density-based methods like DBSCAN and HDBSCAN aim to automate this, they often replace $k$ with other sensitive parameters like "epsilon" or "min-pts," which are equally difficult to tune.

Comparison of required parameters across various clustering algorithms.

Existing automated approaches, such as X-Means, frequently over-estimate the number of clusters or require a user-defined maximum $k$. K*-Means addresses these limitations by providing a truly parameter-free alternative that is as robust and fast as $k$-means but requires zero user intervention.

Methodology: Clustering as Compression

The core of K-Means is the Minimum Description Length (MDL) principle. In this framework, the "best" model is defined as the one that provides the shortest total description of the data. K-Means calculates a "bit cost" comprising three components:

  1. Model Cost: Bits required to store centroid locations.
  2. Index Cost: Bits required to store cluster assignments for each point.
  3. Residual Cost: Bits required to describe the error (distance) between points and their centroids.

The algorithm begins with a single cluster and iteratively performs standard $k$-means "assign" and "update" steps. It incorporates two dynamic operations:

  • Maybe-Split: Each cluster tracks internal "sub-centroids." If splitting a cluster into two reduces the total bit cost, the split is finalized.
  • Maybe-Merge: The algorithm checks if merging the two closest clusters reduces the total bit cost.

By only making changes that mathematically improve the compression (bit cost), K*-Means naturally converges to an optimal $k$.

Experimental Results

The authors tested K*-Means on a wide variety of data types, including synthetic 2D Gaussians, handwritten digits (MNIST/USPS), spoken words, and categorized text. For high-dimensional data, embeddings (e.g., CLIP, Llama-3.1) and UMAP were used for preprocessing.

Performance comparison on synthetic data showing K*-Means' superior accuracy in identifying the correct number of clusters.

Key Findings

  • Accuracy in $k$: On synthetic datasets, K*-Means identified the exact number of clusters with 99.8% accuracy, significantly outperforming HDBSCAN and X-Means.
  • Real-World Performance: On the MNIST dataset, K*-Means achieved 91.26% accuracy and identified 11 clusters (close to the true 10), while X-Means identified 118 clusters.
  • Efficiency: K*-Means is computationally efficient. On the Speech Commands dataset (99k points), it was 50x faster than standard BIC-selection methods.

Discussion and Conclusion

K-Means offers a principled, non-arbitrary stopping criterion for clustering by treating it as an optimization problem of data efficiency. Its ability to optimize the number of clusters during* training makes it faster than "sweeping" methods.

However, like standard $k$-means, K-Means assumes roughly spherical (Gaussian) cluster shapes and may struggle with complex, non-convex geometries. Future work may extend the MDL framework to handle non-spherical clusters or hierarchical structures. Overall, K-Means represents a significant step toward truly automated, parameter-free unsupervised learning.

Summary updated

BibTeX
@misc{mahon2025k,
  author = {Louis Mahon and Mirella Lapata},
  title = {{K*-Means: A Parameter-free Clustering Algorithm}},
  year = {2025},
  eprint = {2505.11904},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2505.11904},
}
Figure