FLS: A New Local Search Algorithm for K-means with Smaller Search Space

Junyu Huang, Qilong Feng, Ziyun Huang, Jinhui Xu, Jianxin Wang

Introduction

The $k$-means problem—partitioning $n$ data points into $k$ clusters to minimize the sum of squared distances—is a cornerstone of unsupervised learning. While the widely used Lloyd’s algorithm is computationally efficient, it frequently converges to poor local optima. Local search methods offer a way to escape these optima by swapping cluster centers with non-center points. However, traditional local search is often computationally prohibitive for large datasets, as it typically evaluates $O(nk)$ possible swap pairs. Modern variants like LS++ improve upon this but can still struggle with scalability or stagnation in complex data landscapes. The authors of this paper propose Fast Local Search (FLS), an algorithm designed to be both theoretically grounded and practically efficient for massive, complex data.

The FLS Algorithm

FLS addresses the computational bottleneck of local search by drastically narrowing the search space from $O(nk)$ to $O(k^2)$. The algorithm employs a three-tiered strategy to find better clustering solutions while maintaining efficiency:

  1. Search-Swap (Local Adjustment): Instead of checking all $n$ points for a swap, FLS only considers the 10-nearest neighbors of each current center. This reduces the candidate swap pairs to a manageable $O(k)$.
  2. Sampling-Swap (Jumping Out): If local adjustments fail to improve the cost, the algorithm uses uniform random sampling to pick a small set of points ($O(k \log 1/\eta)$). This helps the algorithm "jump" out of local optima that are too wide for the nearest-neighbor search to escape.
  3. Random Mutation (Restarting): If both the above fail, FLS performs a random mutation, replacing centers with arbitrary points from the dataset with a small probability ($1/k$). This effectively restarts the search process from a new configuration to prevent stagnation.

The algorithm is built on the $\beta$-average data distribution assumption, which posits that each optimal cluster contains at least a certain fraction ($\beta/k$) of the total points. This assumption allows the authors to prove that FLS provides a $(100 + \epsilon)$-approximate solution in expectation.

Experimental Setup

The performance of FLS was benchmarked against standard Local Search (LS) and LS++ across a variety of synthetic and real-world datasets. These include high-dimensional sets (Dim32), large-scale sets (Birch2, SUSY), and datasets with unbalanced cluster sizes. The "hard instances" (A2, A3, Dim32, Birch2, Unbalance) were specifically chosen because they feature high separation or unbalanced distributions that typically challenge standard algorithms.

Characteristics of the synthetic and real-world datasets used in the evaluation.

Results and Discussion

FLS consistently outperformed existing methods in both accuracy and speed. On "hard" instances like the A2 dataset, FLS achieved a gap to the optimum of only 0.56%, compared to 4.03% for LS++. In several cases, such as the Dim32 and Yeast datasets, FLS reached the optimal solution (0% gap) while LS++ remained trapped.

Comparison of clustering gap (%) at specific time points for LS, LS++, and FLS across various datasets.

The speed improvements are equally notable. For the Yeast dataset, FLS reached a 1% gap in just 3 seconds, whereas LS++ took 128 seconds—a roughly 42x speedup. On the massive 5-million-point SUSY dataset, FLS achieved a 0% gap (relative to the best-known solution) within the fixed time limit, while LS++ was stuck at a 1.98% gap. These results highlight the efficiency of focusing on sparse search spaces and the effectiveness of controlled mutation in global optimization.

Conclusion and Future Work

FLS demonstrates that local search for $k$-means can be both theoretically sound and practically efficient for massive, complex datasets. By focusing on the 10-nearest neighbors and using small random samples, FLS ignores millions of "useless" swap pairs that standard local search would waste time calculating.

While FLS performs exceptionally well in practice, its theoretical approximation ratio $(100 + \epsilon)$ is higher than the best known theoretical ratio for local search ($9 + \epsilon$). Bridging this gap between theory and practice remains an open challenge. Additionally, while the $\beta$-average assumption holds for most real-world benchmarks, datasets with extremely rare clusters (outliers) might require modified sampling strategies.

Summary updated

BibTeX
@inproceedings{huang2022fls,
  author = {Junyu Huang and Qilong Feng and Ziyun Huang and Jinhui Xu and Jianxin Wang},
  title = {{FLS: A New Local Search Algorithm for K-means with Smaller Search Space}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {2022},
  doi = {10.24963/ijcai.2022/429},
}
Figure