pychameleon
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:
- Phase I: partition a k-nearest-neighbor graph into many small sub-clusters via METIS.
- 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
pymetisdependency has no Windows wheels on PyPI. Install it from conda-forge first (conda install -c conda-forge pymetis), thenpip 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.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| chameleon_cluster-0.1.1.tar.gz | 419.4 kB | With provenance | Details for chameleon_cluster-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| chameleon_cluster-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for chameleon_cluster-0.1.1-py3-none-any.whl |
Total release size: 435.6 kB
Release files / chameleon_cluster-0.1.1.tar.gz
| Download URL | chameleon_cluster-0.1.1.tar.gz |
|---|---|
| Size | 419.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ed76979af2c72374f52fef81e963a8ff1b4c1a224933fd487c98cdbd5d77d819
|
|
BLAKE2b-256 checksum How to use checksums |
dca694b95e14ea9a734114701919d93141ca28e02350e39fbc43fc5e09ba7aa6
|
| 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 logRelease files / chameleon_cluster-0.1.1-py3-none-any.whl
| Download URL | chameleon_cluster-0.1.1-py3-none-any.whl |
|---|---|
| Size | 16.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7d52e6e8d9e63f76509b3c16dce4d4266e13dd7c1a81b829413d1086004927e4
|
|
BLAKE2b-256 checksum How to use checksums |
446780cb3c42214e8c67715a054b164d317f0fadefd631e4e2094de89e6f1db8
|
| 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 logSecurity for chameleon-cluster 0.1.1
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.
Attestation for chameleon_cluster-0.1.1.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 logA 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.