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.
Metadata
Release files for impkmeans 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| impkmeans-1.0.2.tar.gz | 4.7 kB | Without provenance | Details for impkmeans-1.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| impkmeans-1.0.2-py3-none-any.whl | Python 3 | none | any | Details for impkmeans-1.0.2-py3-none-any.whl |
Total release size: 9.2 kB
Release files / impkmeans-1.0.2.tar.gz
| Download URL | impkmeans-1.0.2.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6637da409847014ddaa05a5022d67bc347050a35f164e48560ac845987ee4051
|
|
BLAKE2b-256 checksum How to use checksums |
159d8e069b362df6cca0db6de9320c182347ab1576cad8a56a52b1191716da8b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Release files / impkmeans-1.0.2-py3-none-any.whl
| Download URL | impkmeans-1.0.2-py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c56acd45e211519bf06f0ba7dbaa91db4ea13b738a3440a3985006588423d3b0
|
|
BLAKE2b-256 checksum How to use checksums |
04fb3a4b0208d42c1c849bf2645c7eee381d86cb8ec4d2ca3ff6c1e419e431da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Security for impkmeans 1.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.