arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2412.15295cs.DScs.LG
收藏

一维数据的对数时间 K-Means 聚类:带有证明与实现的新方法

Log-Time K-Means Clustering for 1D Data: Novel Approaches with Proof and Implementation

Jake Hyun

AI总结:

针对一维数据聚类效率低下的问题,提出利用排序、前缀和与二分搜索优化的 $k$-means++ 初始化与 Lloyd's algorithm,在保持聚类质量的同时实现超 4500 倍加速,并在 LLM 量化任务中获 300 倍加速。

摘要:

聚类是机器学习中的一项关键任务,$k$-means 因其简单和有效而被广泛使用。虽然一维聚类很常见,但现有方法通常未能利用一维数据的结构,从而导致效率低下。本论文引入了针对 $k$-means++ 初始化和 Lloyd's algorithm 的优化算法,利用排序数据、前缀和与二分搜索来提升计算性能。主要贡献是:(1)一种优化的 $k$-cluster 算法,在贪心 $k$-means++ 初始化中实现 $O(l \cdot k^2 \cdot \log n)$ 复杂度,在 Lloyd's algorithm 中实现 $O(i \cdot k \cdot \log n)$ 复杂度,其中 $l$ 是贪心 $k$-means++ 的局部试验次数,$i$ 是 Lloyd's algorithm 的迭代次数;(2)一种基于二分搜索的双簇算法,实现 $O(\log n)$ 运行时间,并确定性地收敛到 Lloyd's algorithm 的局部最小值。基准测试表明,对于大型数据集,与 scikit-learn 相比实现了超过 4500 倍的加速,同时保持了由簇内平方和(WCSS)衡量的聚类质量。此外,该算法在 LLM 量化任务中实现了 300 倍的加速,突显了其在新兴应用中的实用性。本论文弥合了一维 $k$-means 聚类的理论与实践,在 JIT 优化的开源 Python 库中实现了高效且可靠的算法。

英文摘要:

Clustering is a key task in machine learning, with $k$-means being widely used for its simplicity and effectiveness. While 1D clustering is common, existing methods often fail to exploit the structure of 1D data, leading to inefficiencies. This thesis introduces optimized algorithms for $k$-means++ initialization and Lloyd's algorithm, leveraging sorted data, prefix sums, and binary search for improved computational performance. The main contributions are: (1) an optimized $k$-cluster algorithm achieving $O(l \cdot k^2 \cdot \log n)$ complexity for greedy $k$-means++ initialization and $O(i \cdot k \cdot \log n)$ for Lloyd's algorithm, where $l$ is the number of greedy $k$-means++ local trials, and $i$ is the number of Lloyd's algorithm iterations, and (2) a binary search-based two-cluster algorithm, achieving $O(\log n)$ runtime with deterministic convergence to a Lloyd's algorithm local minimum. Benchmarks demonstrate over a 4500x speedup compared to scikit-learn for large datasets while maintaining clustering quality measured by within-cluster sum of squares (WCSS). Additionally, the algorithms achieve a 300x speedup in an LLM quantization task, highlighting their utility in emerging applications. This thesis bridges theory and practice for 1D $k$-means clustering, delivering efficient and sound algorithms implemented in a JIT-optimized open-source Python library.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑