Conference Paper
Machine Learning
Featured

An efficient k-means clustering algorithm: analysis and implementation

Tapas Kanungo(IBM (United States)), David M. Mount, Nathan S. Netanyahu, Christine Piatko, Ruth Silverman, Angela Y. Wu
July 1, 2002IEEE Transactions on Pattern Analysis and Machine Intelligence5,666 citations

5.7k

Citations

179

Influential Citations

IEEE Transactions on Pattern Analysis and Machine Intelligence

Venue

2002

Year

Abstract

In k-means clustering, we are given a set of n data points in d-dimensional space R/sup d/ and an integer k and the problem is to determine a set of k points in Rd, called centers, so as to minimize the mean squared distance from each data point to its nearest center. A popular heuristic for k-means clustering is Lloyd's (1982) algorithm. We present a simple and efficient implementation of Lloyd's k-means clustering algorithm, which we call the filtering algorithm. This algorithm is easy to implement, requiring a kd-tree as the only major data structure. We establish the practical efficiency of the filtering algorithm in two ways. First, we present a data-sensitive analysis of the algorithm's running time, which shows that the algorithm runs faster as the separation between clusters increases. Second, we present a number of empirical studies both on synthetically generated data and on real data sets from applications in color quantization, data compression, and image segmentation.

Analysis

Why This Paper Matters

K-means clustering is one of the most widely used unsupervised learning algorithms, but its naive implementation scales poorly with large datasets. The filtering algorithm introduced in this paper provides a practical and theoretically grounded acceleration that remains relevant today. By leveraging a kd-tree to prune unnecessary distance computations, the method achieves substantial speedups without sacrificing clustering quality. This work is particularly important for practitioners who need to run k-means on large-scale data in applications like image segmentation and data compression.

The paper's data-sensitive analysis is a key contribution because it explains why the algorithm works well in practice: as clusters become more separated, the filtering becomes more effective. This insight helps users understand when to expect the greatest performance gains.

Technical Contributions

  • Filtering algorithm: A kd-tree-based implementation of Lloyd's algorithm that prunes entire groups of points when they are clearly closer to one center than to others.
  • Data-sensitive runtime analysis: Formal proof that the algorithm's running time improves with increasing cluster separation, providing a theoretical basis for observed efficiency.
  • Empirical validation: Extensive experiments on synthetic data and real-world datasets (color quantization, data compression, image segmentation) demonstrating consistent speedups.
  • Simplicity: The algorithm requires only a kd-tree as its major data structure, making it easy to implement and integrate into existing systems.

Results

The paper reports that the filtering algorithm reduces the number of distance computations per iteration dramatically compared to the naive O(nk) approach. On synthetic data with well-separated clusters, the speedup is particularly pronounced. Real-world experiments show that the algorithm is efficient for practical tasks such as color quantization (reducing millions of colors to a palette) and image segmentation, where it runs orders of magnitude faster than the naive implementation. The authors do not provide exact runtime numbers in the abstract, but the empirical studies confirm the theoretical predictions.

Significance

This paper has had a lasting impact on the clustering community. The filtering algorithm became a standard technique for accelerating k-means and inspired further work on hierarchical and tree-based clustering methods. Its emphasis on data-sensitive analysis set a precedent for understanding algorithm performance in terms of data properties. For AI practitioners, the work provides a reliable, easy-to-implement tool for scaling k-means to large datasets, which remains relevant in modern applications such as large-scale data mining and computer vision.