Skip to main content

Multi-Center Minimum Spanning Tree Clustering algorithm

Project description

PyPI version License: MIT Python 3.7+

Motivation

MCMSTClustering is a minimum-cost MST based clustering algorithm.
It uses MST distances and optional DBSCAN to detect clusters in high-dimensional data.

Installation

pip install mcmst-clust

Usage

import numpy as np
from mcmst_clust import MCMSTClustering
from sklearn.datasets import make_moons

# Generate sample data
X, _ = make_moons(n_samples=200, noise=0.05, random_state=42)

# Create and fit the model
model = MCMSTClustering(N=5, r=0.1, n_micro=3, random_state=42)
labels = model.fit_predict(X)

# Evaluate results
print(f"Number of clusters: {model.n_macro_clusters_}")
print(f"Number of micro-clusters: {model.n_micro_clusters_}")

# Visualize results
from mcmst_clust import plot_clusters_2d
plot_clusters_2d(model, X)

Oerview

MCMSTClustering (Defining Non-Spherical Clusters by using Minimum Spanning Tree over KD-Tree-based Micro-Clusters) is designed to overcome limitations of conventional clustering algorithms when handling:

- High-dimensional data

- Imbalanced datasets

- Clusters with varying densities

- Noisy data/outliers

- Arbitrary-shaped clusters

The algorithm consists of three main steps:

1. Micro-cluster Formation: Defines micro-clusters using a KD-Tree data structure with range search.

2. Macro-cluster Construction: Builds a minimum spanning tree (MST) over the micro-clusters to form macro-clusters.

3. Cluster Regulation: Refines the clusters to improve accuracy and overall clustering quality.

Extensive experiments against state-of-the-art algorithms show that MCMSTClustering achieves high-quality clustering results with acceptable runtime.

Key Features

- Clusters datasets with high quality

- Detects arbitrary-shaped clusters

- Robust against outliers/noisy data

- Handles clusters with varying densities

- Efficient on imbalanced datasets

Advanced Usage

from mcmst_clust import MCMSTClustering, find_optimal_parameters, evaluate_clustering
from sklearn.datasets import load_iris

# Load dataset
data = load_iris()
X = data.data
y = data.target

# Find optimal parameters
result = find_optimal_parameters(X, y, n_iter=50, random_state=42)
print(f"Best parameters: {result['params']}")
print(f"Best ARI: {result['score']:.4f}")

# Use optimal parameters
model = MCMSTClustering(**result['params'], random_state=42)
labels = model.fit_predict(X)

# Evaluate clustering
metrics = evaluate_clustering(y, labels)
for metric_name, value in metrics.items():
    print(f"{metric_name}: {value:.4f}")

Cite

If you use the code in your works, please cite the paper given below:

Şenol, A. MCMSTClustering: defining non-spherical clusters by using minimum 
spanning tree over KD-tree-based micro-clusters. Neural Comput & Applic 35, 
13239–13259 (2023). https://doi.org/10.1007/s00521-023-08386-3

BibTeX

@article{csenol2023mcmstclustering,
  title={MCMSTClustering: defining non-spherical clusters by using minimum spanning tree over KD-tree-based micro-clusters},
  author={{\c{S}}enol, Ali},
  journal={Neural Computing and Applications},
  volume={35},
  number={18},
  pages={13239--13259},
  year={2023},
  publisher={Springer}
}

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

mcmst_clust-1.0.6.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

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

mcmst_clust-1.0.6-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file mcmst_clust-1.0.6.tar.gz.

File metadata

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

File hashes

Hashes for mcmst_clust-1.0.6.tar.gz
Algorithm Hash digest
SHA256 828c69c1817e5245a01b5f64f001ba5f011fdc2fb646a8aa005049c5df9c0cad
MD5 b90d635a1e492a70e24ff2e1b9999fad
BLAKE2b-256 93fb53d321d4f62dc30d729615d710b8bb5b7e15581d9b4a50a245d790e12714

See more details on using hashes here.

File details

Details for the file mcmst_clust-1.0.6-py3-none-any.whl.

File metadata

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

File hashes

Hashes for mcmst_clust-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 cd1e981653b0e8d7b321d14f1f77c4b8b8a4fb810347d00a6f4fe1a00e0f3685
MD5 81480be349ae314da09692b8d96d753f
BLAKE2b-256 ad27c56496e5c786a969e9993267982aa04bdd40eaa0c8ec1ffd91519ef7b8b0

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