Skip to main content

ImpKMeans: Improved K-Means initialization using KDE + KD-Tree

Project description

PyPI version License: MIT Python 3.7+

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

🚀 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

impkmeans-1.0.1.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

impkmeans-1.0.1-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file impkmeans-1.0.1.tar.gz.

File metadata

  • Download URL: impkmeans-1.0.1.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for impkmeans-1.0.1.tar.gz
Algorithm Hash digest
SHA256 5ae3d295b925df4729e44c7d90a9be36672fa7d90fb6658ff83d8394dc338622
MD5 01e5e771b29e7d7dabacf6adc8826ad5
BLAKE2b-256 44c6ad8dcbe36e467ecd75243e8481898016d1b107a31bc917a08129fcdf97c7

See more details on using hashes here.

File details

Details for the file impkmeans-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: impkmeans-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for impkmeans-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 040f3c7bdf065b3c69e200b39a01f323c49854ae601e2fce03d0c6e456bd0c02
MD5 673d3fad11213a9a34655b80c73cf985
BLAKE2b-256 ec7594ab7f6b9046d4e3e15845610f5df0a8d0ff0519e2b91942f8a9ee0b123d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page