kmeans-seeding: Fast k-means++ Initialization
kmeans-seeding is a high-performance Python package providing state-of-the-art algorithms for k-means++ initialization. All algorithms are implemented in C++ with Python bindings for maximum speed while maintaining an easy-to-use scikit-learn compatible API.
Quick Example
from kmeans_seeding import rskmeans
from sklearn.cluster import KMeans
import numpy as np
# Generate sample data
X = np.random.randn(10000, 50)
# Fast initialization with RS-k-means++
centers = rskmeans(X, n_clusters=100, index_type='FastLSH')
# Use with scikit-learn
kmeans = KMeans(n_clusters=100, init=centers, n_init=1)
labels = kmeans.fit_predict(X)
Key Features
✅ Multiple Algorithms: RS-k-means++, AFK-MC², Fast-LSH, standard k-means++
✅ High Performance: C++ implementation, 10-100× faster than pure Python
✅ Flexible: Optional FAISS integration for approximate nearest neighbors
✅ Easy to Use: Scikit-learn compatible API, works as drop-in replacement
✅ Well-Tested: Comprehensive test suite with >95% code coverage
✅ Production Ready: Used in research and production environments
When to Use
Use kmeans-seeding when you need:
Fast initialization for large datasets (n > 10,000 samples)
High-dimensional clustering (d > 50 features)
Better initialization than sklearn’s default k-means++
Reproducible seeding with theoretical guarantees
Multiple seeding options to optimize speed/quality tradeoff
Contents
Algorithm Documentation
API Reference
Additional Information