Skip to main content

tests PyPI

pbhc is a minimal parallel Bayesian hierarchical clustering (BHC) implementation in JAX that runs on GPU/TPU/CPU. Clustering is constrained to a graph: only clusters joined by an edge may merge, so on a pixel grid every cluster is spatially contiguous. Instead of BHC's one-merge-at-a-time greedy loop, every cluster merges with its most probable neighbour in the same round (Borůvka-style), so the number of rounds grows roughly with the log of the number of points.

Each cluster follows a diagonal Normal-Normal model, x ~ N(mu, sigma2), mu ~ N(0, tau2), with a Dirichlet process prior of concentration alpha (Heller & Ghahramani, 2005). Merges of several children at once use the product over children of Bayesian rose trees, and merging stops when no merge has posterior probability above threshold (0.5 by default).

Usage

import jax
import jax.numpy as jnp
import pbhc

jax.config.update("jax_enable_x64", True)  # recommended for large inputs

# 100 points in a line: the first 50 around 0, the last 50 around 10
X = jax.random.normal(jax.random.key(0), (100, 3)).at[50:].add(10)

# edges between consecutive points (only connected clusters can merge)
i, j = jnp.arange(99), jnp.arange(1, 100)

# sigma2: spread inside a cluster, from differences between neighbours
# tau2: spread between clusters, from the variance of the whole data
sigma2 = 0.5 * jnp.mean((X[i] - X[j]) ** 2)
tau2 = jnp.var(X)

state = pbhc.fit(X, i, j, sigma2=sigma2, tau2=tau2)
print(state.labels)  # [0 0 ... 0 1 1 ... 1]

Installation

pbhc can be installed from PyPI via pip

pip install pbhc

Citation

If you use pbhc in your research and need to reference it, please cite it as follows:

@software{alonso_pbhc,
  author = {Alonso, Albert},
  title = {pbhc: Minimal Parallel Bayesian Hierarchical Clustering in JAX},
  url = {https://github.com/alonfnt/pbhc},
  version = {0.1.0}
}

Metadata

Release files for pbhc 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 pbhc 0.1.0
File Size Uploaded Provenance
pbhc-0.1.0.tar.gz 6.4 kB With provenance Details

Built distribution (wheel)

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

Total release size: 13.8 kB

Release files / pbhc-0.1.0.tar.gz

Download URL pbhc-0.1.0.tar.gz
Size 6.4 kB
Tags Source
SHA-256 checksum
How to use checksums
bc7cc3fe0b8f057ab83bcd773e5da51825064cddb3c9d9c0d07817ede3a1ad5b
BLAKE2b-256 checksum
How to use checksums
579e6eff778f2879847e4cda2b0b3c0c3ffd6ae9288ef157152a38eeb74ed5a0
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 20, 2026.

Transparency log

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

Download URL pbhc-0.1.0-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
55c09bde6503e7d85502745bf5341b5f13c0a6010f57c15cfd3be36dafb1f2c4
BLAKE2b-256 checksum
How to use checksums
49191933e09be7f2ffafca4f06e01eb38def7518920a78a6531cc17084299d06
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 20, 2026.

Transparency log

Security for pbhc 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

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

Select from 2 files

Attestation for pbhc-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 20, 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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

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