Skip to main content

MCMSTStream: applying minimum spanning tree to KD-tree-based micro-clusters to define arbitrary-shaped clusters in streaming data

Project description

MCMSTStream

PyPI version Python License: MIT Paper

MCMSTStream is a density-based stream clustering algorithm that applies a Minimum Spanning Tree (MST) over KD-tree-based micro-clusters to define arbitrary-shaped clusters in streaming data.

Published in Neural Computing and Applications (2024) 36:7025–7042.

Key features

  • Online (sliding-window) stream clustering
  • Detects arbitrary-shaped (non-spherical) clusters
  • Robust to outliers and noisy data
  • Handles high-dimensional streams via KD-tree range search
  • Scikit-learn-style API: fit, partial_fit, fit_predict, predict, get_params, set_params

Installation

pip install mcmststream

For the built-in visualization support:

pip install "mcmststream[viz]"

Quick start

import numpy as np
from sklearn.preprocessing import MinMaxScaler
from sklearn.metrics import adjusted_rand_score
from mcmststream import MCMSTStream, load_exclastar

# Load the bundled ExclaStar benchmark dataset
X, y_true = load_exclastar()
X = MinMaxScaler().fit_transform(X)

clusterer = MCMSTStream(
    W=270,        # sliding window width
    N=2,          # min points to define a micro-cluster
    r=0.14,       # micro-cluster radius
    n_micro=2,    # min micro-clusters to define a macro-cluster
    random_state=42,
    keep_history=True,
)

# Process the stream point by point
for point in X:
    clusterer.partial_fit(point)

print("ARI = %.4f" % adjusted_rand_score(y_true, clusterer.history_labels_))

Optional visualization of the current window:

clusterer.visualize(title="MCMSTStream on ExclaStar")

Parameters

Parameter Description Paper symbol
W Sliding window width W
N Minimum number of points within radius r to define a micro-cluster N
r Micro-cluster radius; micro-clusters within 2r are linked by the MST r
n_micro Minimum number of micro-clusters to form a macro-cluster n_micro

How it works

  1. Micro-clusters are formed with a KD-tree range search: at least N points within radius r.
  2. Macro-clusters are built by running Prim's MST over micro-cluster centers, connecting those within 2r.
  3. As the stream evolves, micro/macro-clusters are updated, merged, or deleted, adapting to concept drift.

Citation

If you use this package in your research, please cite:

@article{erdinc2024mcmststream,
  title   = {MCMSTStream: applying minimum spanning tree to KD-tree-based
             micro-clusters to define arbitrary-shaped clusters in streaming data},
  author  = {Erdin{\c{c}}, Berfin and Kaya, Mahmut and {\c{S}}enol, Ali},
  journal = {Neural Computing and Applications},
  volume  = {36},
  number  = {13},
  pages   = {7025--7042},
  year    = {2024},
  doi     = {10.1007/s00521-024-09443-1}
}

Related projects

License

MIT — see LICENSE.

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

mcmststream-1.1.0.tar.gz (23.4 kB view details)

Uploaded Source

Built Distribution

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

mcmststream-1.1.0-py3-none-any.whl (19.3 kB view details)

Uploaded Python 3

File details

Details for the file mcmststream-1.1.0.tar.gz.

File metadata

  • Download URL: mcmststream-1.1.0.tar.gz
  • Upload date:
  • Size: 23.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mcmststream-1.1.0.tar.gz
Algorithm Hash digest
SHA256 5f135a12bb2495136d9a542457c89ecebbd6e73f10cd926407cd21d944307fec
MD5 4835d94f70e89b706a5572bb04bd01b9
BLAKE2b-256 d8f50993de487e466c6503bf739ce661014719a594204999695bc9d89398b52a

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcmststream-1.1.0.tar.gz:

Publisher: publish.yml on senolali/MCMSTStream

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mcmststream-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: mcmststream-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mcmststream-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d73b561f1430b97a5d09591d124dbab977c89b01dcfca3b580a9bb4b5392a225
MD5 0fea46132aa1beb039218fb0613a42a5
BLAKE2b-256 f12ff9b6ffc3bb0bce8c6a028e9207feec140b6330d4befd754d37773263ab52

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcmststream-1.1.0-py3-none-any.whl:

Publisher: publish.yml on senolali/MCMSTStream

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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