Skip to main content

PyPI Docs CI

evoc-rs

Python bindings for evoc-rs: EVoC clustering for high-dimensional embeddings. The Rust crate does the work. This is a thin scikit-learn shaped layer over it.

Documentation: https://gregorlueg.github.io/evoc-rs/

This package versions separately from the Rust crate. Changes here are in python/CHANGELOG.md; the crate's are in CHANGELOG.md.

Install

You can just install from PyPI.

uv pip install evoc-rs

Use

import numpy as np
import evoc_rs

rng = np.random.default_rng(0)
X = np.vstack([rng.normal(c * 20, 1, (500, 32)) for c in range(4)]).astype(np.float32)

model = evoc_rs.EVoC(n_neighbours=15).fit(X)

model.labels_  # the most persistent layer, -1 is noise
model.cluster_layers_  # (n_layers, n_samples), finest first
model.persistence_scores_  # (n_layers,), higher is more stable

Parameters go in the constructor, data goes into fit, results come off the fitted estimator. get_params, set_params, fit and fit_predict are all there, so it drops into scikit-learn pipelines and GridSearchCV without scikit-learn being an install requirement.

The hierarchy is the point

Most clustering libraries hand you one labelling. EVoC hands you several, one per granularity, ranked by how stable each is. labels_ picks the most persistent for you, but the interesting bit can be a layer or two either side:

for layer, score in zip(model.cluster_layers_, model.persistence_scores_):
    print(f"{layer.max() + 1:3d} clusters, persistence {score:.3f}")

Already know how many clusters you want? Pass approx_n_clusters and the finest layer is binary-searched for it, returning a single layer.

model = evoc_rs.EVoC(approx_n_clusters=8).fit(X)

How it works

Six stages, all in Rust:

  1. Approximate kNN graph, via ann-search-rs.
  2. Fuzzy simplicial set over that graph.
  3. Label-propagation initialisation.
  4. UMAP-like node embedding with a repulsion term tuned by noise_level.
  5. MST over mutual reachability distances in the embedding.
  6. Cluster layers pulled out of the tree by persistence.

Clustering the embedding rather than the original space is what makes it fast and what makes the hierarchy meaningful.

kNN backends

ann_algorithm picks the backend for stage 1. nndescent is the default and the right first choice for a self-kNN graph. exhaustive is exact, and worth it below roughly 10k points. hnsw, annoy, ivf, kmknn and balltree are all there if you have a reason.

Bring your own graph instead, if you already have one:

model = evoc_rs.EVoC().fit(X, precomputed_knn=(indices, distances))

Both arrays are (n_samples, k) and exclude self.

GPU

EVoCGpu moves the kNN stage onto the GPU via wgpu and leaves everything downstream on the CPU. That only pays off when the search dominates: many points, high dimension, or an exhaustive search. float32 only, because WGSL has no f64.

if evoc_rs.gpu_available():
    model = evoc_rs.EVoCGpu(n_neighbours=15).fit(X)

gpu_available() answers both "was this wheel built with GPU support" and "is there an adapter here" at once. The published wheel carries it.

MLX on Apple Silicon

Experimental, and not in the published wheel: build from source on a Mac with mlx-c installed.

brew install mlx-c
cd python && maturin develop --release --features mlx

That adds exhaustive_mlx, ivf_mlx and nndescent_mlx as ann_algorithm options on the plain EVoC. The kNN stage runs on the Apple GPU through MLX in float32, everything after it stays on the CPU.

if evoc_rs.mlx_available():
    model = evoc_rs.EVoC(n_neighbours=15, ann_algorithm="nndescent_mlx").fit(X)

mlx_available() is fixed at build time. Without mlx-c the build warns and leaves MLX out, and asking for an *_mlx backend raises with a pointer to the build flag.

Threads

evoc_rs.set_num_threads(8)  # cap it
evoc_rs.set_num_threads(0)  # back to one per core

Credit

Port of evoc by Leland McInnes. Where behaviour diverges, the Python original is the source of truth.

Metadata

Release files for evoc-rs 0.5.0

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

Built distributions (wheels)

Table of built distributions (wheels) for evoc-rs 0.5.0
File Interpreter ABI Platform Actions
evoc_rs-0.5.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for evoc_rs-0.5.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
evoc_rs-0.5.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for evoc_rs-0.5.0-cp310-abi3-macosx_11_0_arm64.whl
evoc_rs-0.5.0-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for evoc_rs-0.5.0-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 42.0 MB

Release files / evoc_rs-0.5.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL evoc_rs-0.5.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 14.9 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
3c4e86bd75351b655d36d0f63d56ca1e87a2b5f864d830873ed02ede3cd2683e
BLAKE2b-256 checksum
How to use checksums
ca0813b5602c4f1fbe0f74cc82934f7638248785819dd9f94f79b2e69469fef3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 18, 2026.

Transparency log

Release files / evoc_rs-0.5.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL evoc_rs-0.5.0-cp310-abi3-macosx_11_0_arm64.whl
Size 13.1 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
35562f119537a0c69925b908ba09a85e9b2f0153ca60559dde434a5abfb5c96b
BLAKE2b-256 checksum
How to use checksums
2f20859b34b7c9a2d29332342d9d79d3976374c3469d7d824b8ab279b7faae00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 18, 2026.

Transparency log

Release files / evoc_rs-0.5.0-cp310-abi3-macosx_10_12_x86_64.whl

Download URL evoc_rs-0.5.0-cp310-abi3-macosx_10_12_x86_64.whl
Size 14.0 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
3ed3d81ed3d5c8cb0b80376d2ae630a15d345449895af15e94d3c62848807747
BLAKE2b-256 checksum
How to use checksums
5a91fc3c7dd6ac1e5b72f5fdf28e194c208eec2803fd58f3300df67da9947650
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 18, 2026.

Transparency log

Security for evoc-rs 0.5.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

All 3 files in this release have been uploaded with provenance metadata.

Select from 3 files

Attestation for evoc_rs-0.5.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

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 Nov 18, 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