Skip to main content

pychameleon

Implementation of the CHAMELEON hierarchical clustering algorithm (Karypis, Han, Kumar, 1999) with a scikit-learn compatible API.

CHAMELEON discovers clusters of arbitrary shapes, densities, and sizes by using a two-phase approach:

  1. Phase I: partition a k-nearest-neighbor graph into many small sub-clusters via METIS.
  2. Phase II: agglomeratively merge sub-clusters using dynamic modeling — decisions consider each cluster's internal inter-connectivity and closeness, not a fixed global threshold.

Installation

uv add chameleon-cluster        # with uv
# or
pip install chameleon-cluster   # with pip

The distribution is named chameleon-cluster; the import name is pychameleon.

Windows: the pymetis dependency has no Windows wheels on PyPI. Install it from conda-forge first (conda install -c conda-forge pymetis), then pip install chameleon-cluster.

Quick start

import numpy as np
from pychameleon import Chameleon

X = np.random.rand(500, 2)

model = Chameleon(n_clusters=5, k_nn=10, min_cluster_size=0.025, alpha=2.0)
labels = model.fit_predict(X)

print(f"Found {model.n_clusters_} clusters, labels: {np.unique(labels)}")

Parameters

Parameter Default Description
n_clusters 8 Target number of final clusters
k_nn 10 Number of neighbors in the k-NN graph
min_cluster_size 0.025 Minimum Phase-I sub-cluster size (fraction of n if < 1, else absolute count)
alpha 2.0 Exponent for relative closeness in the merge score: RI · RC^alpha

Development

git clone https://github.com/oszypczy/pychameleon.git
cd pychameleon
uv sync --all-extras

uv run pytest           # tests + coverage
uv run ruff check .     # lint
uv run mypy src/        # type check

References

  • Karypis, G., Han, E.-H., & Kumar, V. (1999). Chameleon: hierarchical clustering using dynamic modeling. Computer, 32(8), 68–75.
  • Karypis, G., & Kumar, V. (1998). A fast and high quality multilevel scheme for partitioning irregular graphs. SIAM J. Sci. Comput., 20(1), 359–392.

License

MIT

Metadata

Release files for chameleon-cluster 0.1.0

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

Source distribution (sdist)

Source distribution for chameleon-cluster 0.1.0
File Size Uploaded Provenance Actions
chameleon_cluster-0.1.0.tar.gz 419.2 kB With provenance Details for chameleon_cluster-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for chameleon-cluster 0.1.0
File Interpreter ABI Platform Actions
chameleon_cluster-0.1.0-py3-none-any.whl Python 3 none any Details for chameleon_cluster-0.1.0-py3-none-any.whl

Total release size: 435.2 kB

Release files / chameleon_cluster-0.1.0.tar.gz

Download URL chameleon_cluster-0.1.0.tar.gz
Size 419.2 kB
Tags Source
SHA-256 checksum
How to use checksums
6134653f729ee67bce236740c507d890173de159ac159f7212e525aeb0cc12ef
BLAKE2b-256 checksum
How to use checksums
17115dc6d720a9a0f25720a5e773b880cf92e17c22e5f4a830fbf2c629003eb0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 11, 2026.

Transparency log

Release files / chameleon_cluster-0.1.0-py3-none-any.whl

Download URL chameleon_cluster-0.1.0-py3-none-any.whl
Size 16.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7431d3a2e39309de8aac4b792130bfd2626b787834189d29dc13d0a051333e41
BLAKE2b-256 checksum
How to use checksums
b26a0c195e7a0ee7495584fd922924672d7c525458b11bda1a29a879da6c420c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 11, 2026.

Transparency log

Security for chameleon-cluster 0.1.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for chameleon_cluster-0.1.0.tar.gz

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 Oct 11, 2026.

Transparency log

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.

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