Skip to main content

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=190,        # sliding window width
    N=2,          # min points to define a micro-cluster
    r=0.23,       # micro-cluster radius
    n_micro=2,    # min micro-clusters to define a macro-cluster
    dense_mc_promotion=True,
    random_state=42,
    keep_history=True,
)

# Process the stream point by point
for point in X:
    clusterer.partial_fit(point)
    clusterer.visualize(title="MCMSTStream on ExclaStar") # to see step-by-step visual results
    

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
dense_mc_promotion If True, a component whose total point count is ≥ n_micro * N also becomes a macro-cluster even with fewer than n_micro micro-clusters (extension beyond the paper; default False) —

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}
}

License

MIT — see LICENSE.

Metadata

Release files for mcmststream 1.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mcmststream 1.2.3
File Size Uploaded
mcmststream-1.2.3.tar.gz 24.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mcmststream 1.2.3
File Interpreter ABI Platform
mcmststream-1.2.3-py3-none-any.whl Python 3 none any Details

Total release size: 44.6 kB

Release files / mcmststream-1.2.3.tar.gz

Download URL mcmststream-1.2.3.tar.gz
Size 24.7 kB
Tags Source
SHA-256 checksum
How to use checksums
4a58eee45ef750c8d33ef758ed84dfdc2af306af46adb8cdb183d2d130bb28d1
BLAKE2b-256 checksum
How to use checksums
28b838acddad5fc647e460ab50058374ef023dd2f018b0ce15da8f3f8d69edec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 6, 2026.

Transparency log

Release files / mcmststream-1.2.3-py3-none-any.whl

Download URL mcmststream-1.2.3-py3-none-any.whl
Size 19.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
61d91c0cdafc7c5c8b73e0f3a5e70403cfcc599ee594aee890c051b8e65f55bc
BLAKE2b-256 checksum
How to use checksums
9944818691409c3c6f7ada6b20dbac6875883ccbee2d0f9b5e113085a2887694
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 6, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.2.3 This release

2 release files

1.2.2

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.4

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page