ImpKMeans: Improved K-Means initialization using KDE + KD-Tree
Project description
ImpKMeans
ImpKMeans is an improved version of the K-Means clustering algorithm, designed to automatically determine high-quality initial centroids using:
- Multivariate Kernel Density Estimation (KDE)
- KD-Tree–based radius suppression
- Mode-seeking peak extraction
Motivation
K-Means often performs poorly when its initial centroids are chosen randomly. The paper shows that selecting centroids from KDE-based density peaks and filtering them with a KD-Tree radius rule leads to more accurate and stable clustering. ImpKMeans implements this idea to provide a simple, effective improvement over standard K-Means initialization.
🚀 Features
- KDE-based high-density region detection
- Intelligent centroid selection via KD-Tree radius filtering
- Deterministic behavior with
random_state - Fully compatible with scikit-learn API (
fit,fit_predict,predict,get_params,set_params) - Lightweight and fast
📦 Installation
Install directly from PyPI:
pip install impkmeans
Basic Usage
from sklearn.datasets import load_iris
from impkmeans import ImpKMeans
from sklearn.metrics.cluster import adjusted_rand_score
# Load dataset
data = load_iris()
X, y = data.data, data.target
model = ImpKMeans(k=7, r=0.7245, random_state=42)
labels = model.fit_predict(X)
ARI=adjusted_rand_score(y, labels)
print("Adjusted Rand Index = %0.4f"%ARI)
Cite
If you use the code in your works, please cite the paper given below:
Şenol, A. (2024). Impkmeans: An improved version of the k-means algorithm, by determining
optimum initial centroids, based on multivariate kernel density estimation and kd-tree.
Acta Polytechnica Hungarica, 21(2), 111-131.
@article{csenol2024impkmeans,
title={Impkmeans: An improved version of the k-means algorithm, by determining optimum initial centroids, based on multivariate kernel density estimation and kd-tree},
author={{\c{S}}enol, Ali},
journal={Acta Polytechnica Hungarica},
volume={21},
number={2},
pages={111--131},
year={2024}
}
License
This project is licensed under the MIT License. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file impkmeans-1.0.2.tar.gz.
File metadata
- Download URL: impkmeans-1.0.2.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6637da409847014ddaa05a5022d67bc347050a35f164e48560ac845987ee4051
|
|
| MD5 |
34e032fe720eb5766d8535fba6f747e7
|
|
| BLAKE2b-256 |
159d8e069b362df6cca0db6de9320c182347ab1576cad8a56a52b1191716da8b
|
File details
Details for the file impkmeans-1.0.2-py3-none-any.whl.
File metadata
- Download URL: impkmeans-1.0.2-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c56acd45e211519bf06f0ba7dbaa91db4ea13b738a3440a3985006588423d3b0
|
|
| MD5 |
2e98dccf4422963918bd448210f3da24
|
|
| BLAKE2b-256 |
04fb3a4b0208d42c1c849bf2645c7eee381d86cb8ec4d2ca3ff6c1e419e431da
|