Skip to main content

isodistrreg: Python bindings

Python bindings for Isotonic Distributional Regression (IDR) and Survival-IDR (S-IDR), built with PyO3 and maturin. See the main README for background.

Installation

pip install isodistrreg

Pre-built wheels are provided for Linux, macOS, and Windows on CPython 3.13+. On other platforms pip builds from the source distribution, which requires a Rust toolchain.

The scikit-learn–compatible estimator is available through an optional extra:

pip install "isodistrreg[scikit-learn]"

Examples

We use numpy to set up a toy problem, but plain python lists can also be used.

Precision

CDF outputs (cdf, cdf_at, cdf_grid) are always np.float32. Covariates and thresholds are stored at the dtype of the input arrays passed to IDR(...): float32 inputs stay float32, float64 inputs stay float64, and .X / .thresholds return zero-copy views at the storage dtype. See the docstring on IDR.cdf and IDR.from_cdfs in _core.pyi for the full rules.

Example 1: Covariate 1-dimensional, outcome censored

import numpy as np
# we visualize with matplotlib
from matplotlib import pyplot as plt
from isodistrreg import IDR

# Generate an instance of increasing conditional CDFs with censoring, and a one-dimensional covariate
n = 500
rng = np.random.default_rng(seed=123)
x = rng.uniform(size=n)
y = x + rng.uniform(size=n)
c = x + rng.uniform(size=n)

t = np.minimum(y, c)
d = y <= c

# Fit the IDR / S-IDR model, censoring is indicated by "False"
fit = IDR(t, x, d)

# Sorted and deduplicated covariates and thresholds are available
sorted_x = fit.X
sorted_y = fit.thresholds

# Estimate and plot the complete distributional estimate
cdf_for_each_x = fit.cdf(sorted_x)
def plot_cdfs_nicely(cdfs, centers, times):
    """Plot a picture with the right scale; plt.imshow is simpler, but spacing along the axis is not to scale"""
    plt.pcolormesh(
        [centers[0] - (centers[1] - centers[0]) / 2]
            + list((centers[1:] + centers[:-1]) / 2)
            + [centers[-1] + (centers[-1] - centers[-2]) / 2],
        list(times) + [times[-1] + (times[-1] - times[0]) / len(times)],
        cdfs.T,
        vmin=0.0,
        vmax=1.0,
    )
plot_cdfs_nicely(cdf_for_each_x, sorted_x, sorted_y)
plt.colorbar()

# Estimate and plot the mean
mean_for_each_x = fit.predict(sorted_x)
# Due to censoring, the estimated sub-CDF may not always have a mean
plt.plot(sorted_x, sorted_x + 0.5, color="lightblue", label="true mean")
plt.plot(sorted_x, mean_for_each_x, color="red", label="mean")

# Estimate and plot quantiles
probabilities = np.array([0.2, 0.8])
quantiles = fit.quantile(sorted_x[:, np.newaxis], probabilities)
plt.plot(sorted_x, quantiles, label=[f"{p} quantile" for p in probabilities])

plt.legend(loc="lower right")
plt.show()

Example 2: Covariate 3-dimensional

import numpy as np
from isodistrreg import IDR

## toy data (3-dimensional covariate)
X = np.column_stack([np.arange(1, 5)] * 3)
y = np.array([1, 0, 2, 2])

## fit
idr_fit = IDR(X = X, y = y)

## get CDF for new x at all relevant thresholds
new_x = np.array([[1, 1, 1], [1.5, 1.5, 1.5]])
idr_fit.cdf(new_x) # (one CDF per row = per x)

## broadcasting
idr_fit.cdf_at(new_x, 0) # (evaluate CDF at 0 for all covariates)
idr_fit.cdf_at(new_x, [0,1]) # (evaluate CDF for x1 at 0, x2 at 1)
idr_fit.cdf_at(new_x, np.column_stack([[1, 2, 3], [0, 1, 2]])) # (CDF at 1,2,3 for x1, and 0,1,2 for x2)

## same for quantiles
idr_fit.quantile(new_x, 0.5)
idr_fit.quantile(new_x, [0.25, 0.5])
idr_fit.quantile(new_x, np.column_stack([[0.25, 0.5, 0.75], [0.1, 0.2, 0.3]]))

# Fast grid evaluation for 1-dimensional covariate
X = np.arange(5)
y = np.arange(5)
idr_fit = IDR(X = X, y = y)
idr_fit.cdf_grid(X, y) # (CDF at all covariate-threshold-combinations)

References

Henzi, A., Ziegel, J. and Gneiting, T. (2021). Isotonic distributional regression. J R Stat Soc Series B, 83: 963–993. https://doi.org/10.1111/rssb.12450

Henzi, A., Moesching, A. and Duembgen, L. (2022). Accelerating the Pool-Adjacent-Violators Algorithm for Isotonic Distributional Regression. Methodol Comput Appl Probab. https://doi.org/10.1007/s11009-022-09937-2

Bladt, M., Henzi, A., van den Heuvel, B. and Ziegel, J. (2026). Survival Isotonic Distributional Regression. arXiv preprint arXiv:2608.02914. https://arxiv.org/abs/2608.02914

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

isodistrreg-0.6.0.tar.gz (345.1 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

isodistrreg-0.6.0-cp313-abi3-win_amd64.whl (2.0 MB view details)

Uploaded CPython 3.13+Windows x86-64

isodistrreg-0.6.0-cp313-abi3-manylinux_2_34_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.13+manylinux: glibc 2.34+ x86-64

isodistrreg-0.6.0-cp313-abi3-manylinux_2_34_aarch64.whl (1.8 MB view details)

Uploaded CPython 3.13+manylinux: glibc 2.34+ ARM64

isodistrreg-0.6.0-cp313-abi3-macosx_11_0_arm64.whl (1.6 MB view details)

Uploaded CPython 3.13+macOS 11.0+ ARM64

isodistrreg-0.6.0-cp313-abi3-macosx_10_12_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.13+macOS 10.12+ x86-64

File details

Details for the file isodistrreg-0.6.0.tar.gz.

File metadata

  • Download URL: isodistrreg-0.6.0.tar.gz
  • Upload date:
  • Size: 345.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for isodistrreg-0.6.0.tar.gz
Algorithm Hash digest
SHA256 0ba1bdcbe4302b253eb0264373f6ad0b91ee483877021db411951fdcb97db0ec
MD5 577afc81b233611b67c7534a768df44e
BLAKE2b-256 d4d5333f31ebe3d672f07b8bbb5b9c615bfd91fa8a96078838575bf847cf0d1d

See more details on using hashes here.

Provenance

The following attestation bundles were made for isodistrreg-0.6.0.tar.gz:

Publisher: release.yml on AlexanderHenzi/isodistrreg

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file isodistrreg-0.6.0-cp313-abi3-win_amd64.whl.

File metadata

  • Download URL: isodistrreg-0.6.0-cp313-abi3-win_amd64.whl
  • Upload date:
  • Size: 2.0 MB
  • Tags: CPython 3.13+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for isodistrreg-0.6.0-cp313-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 086ba4e071009b14d259b3f5d2b57758fbba456cfab5d2c2595a00d97e468172
MD5 6c87ba90f88fb26933cced69fb0c2635
BLAKE2b-256 7463043086dec5d38b2df5bf5b6745cb9dd8dfa216f04093515a9d83b360163d

See more details on using hashes here.

Provenance

The following attestation bundles were made for isodistrreg-0.6.0-cp313-abi3-win_amd64.whl:

Publisher: release.yml on AlexanderHenzi/isodistrreg

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file isodistrreg-0.6.0-cp313-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for isodistrreg-0.6.0-cp313-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 b67e1dfe3517cdb17263acd995ba3b74aad444fbf3f61e84c9ed8f4056a5c71b
MD5 2aba10adf2a3aa172df03cd69873c790
BLAKE2b-256 2089c868bdeb1d83c7753da34389e2afdc16726ef1ea3a1e2efbfe7b33c50cca

See more details on using hashes here.

Provenance

The following attestation bundles were made for isodistrreg-0.6.0-cp313-abi3-manylinux_2_34_x86_64.whl:

Publisher: release.yml on AlexanderHenzi/isodistrreg

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file isodistrreg-0.6.0-cp313-abi3-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for isodistrreg-0.6.0-cp313-abi3-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 64125d014d93c6ab890cb9963ed2ac0c7fca29daafa80e0507af318662c0b7a5
MD5 d50a7b8eaba2f5346a02b9ed452a9355
BLAKE2b-256 6e5b2e04d175a3f6e6188c18e21341ca21cbd439a4df5402d8878876957f49f1

See more details on using hashes here.

Provenance

The following attestation bundles were made for isodistrreg-0.6.0-cp313-abi3-manylinux_2_34_aarch64.whl:

Publisher: release.yml on AlexanderHenzi/isodistrreg

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file isodistrreg-0.6.0-cp313-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for isodistrreg-0.6.0-cp313-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 33560d304d1dd5900e1925e328683083694069a11f33aada7b568c8e2ea24508
MD5 c461c5c83e5d4c62fd03370c276b2c03
BLAKE2b-256 e72f42838e94ad105609f6a61f48de9f0d03673106ec51dd7de2c7a7037438c2

See more details on using hashes here.

Provenance

The following attestation bundles were made for isodistrreg-0.6.0-cp313-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on AlexanderHenzi/isodistrreg

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file isodistrreg-0.6.0-cp313-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for isodistrreg-0.6.0-cp313-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a2e9742a44d59950a37a4b6678d37a1718251962050c9bdd5f1a87aee2ddc415
MD5 c5122418e2a713a7ed302679e3fd213f
BLAKE2b-256 a15adc5308817fdaf4f13d7a5b120c2174c88c7eed7e73b80ac04a93a08862d9

See more details on using hashes here.

Provenance

The following attestation bundles were made for isodistrreg-0.6.0-cp313-abi3-macosx_10_12_x86_64.whl:

Publisher: release.yml on AlexanderHenzi/isodistrreg

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.6.0 This release

6 files

0.5.2

6 files

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