Skip to main content

pychameleon

PyPI CI Docs

Documentation: https://chameleon-cluster.readthedocs.io

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.

Citing

If you use this package, please cite the original paper (above) and this software — see CITATION.cff or the Cite this repository button on GitHub.

License

MIT

Metadata

Release files for chameleon-cluster 0.1.2

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.2
File Size Uploaded Provenance Actions
chameleon_cluster-0.1.2.tar.gz 419.6 kB With provenance Details for chameleon_cluster-0.1.2.tar.gz

Built distribution (wheel)

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

Total release size: 435.8 kB

Release files / chameleon_cluster-0.1.2.tar.gz

Download URL chameleon_cluster-0.1.2.tar.gz
Size 419.6 kB
Tags Source
SHA-256 checksum
How to use checksums
5958d9c49bd072fea988a83bae02bf0f5dad51e8a6fa0d76cb3f96caeaa0deed
BLAKE2b-256 checksum
How to use checksums
43ac20f84c0a5adfa80c0c1e93fb8a2fc885c4035e562ecff95cc681943b351d
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.2-py3-none-any.whl

Download URL chameleon_cluster-0.1.2-py3-none-any.whl
Size 16.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5d47e65b8ecf47a07bcc84ff5cfcfeef547e7e62518dd5572276c38efb15010d
BLAKE2b-256 checksum
How to use checksums
79d8ba17b760bad20a63a898f359ee7b2d7cdabe4d1448fd685fb5e09f84f854
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.2

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.2.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