Skip to main content

Conformity

Point predictions with calibrated uncertainty.

Regression intervals · Classification sets · Scikit-learn workflows

Python 3.9+ Tests PyPI

Quick start · Documentation · API reference · Theory · Development


A point model tells you its best answer. Conformity helps you ask how uncertain that answer is, using independent held-out observations to calibrate prediction intervals or sets of plausible class labels. Wrap a scikit-learn estimator or pipeline, keep ordinary point predictions for model development, and request conformal output when your decision needs a range or several candidates.

Installation

uv add conformity-calib
# Or:
pip install conformity-calib

Requires Python 3.9+, NumPy >=2.0.2 and scikit-learn >=1.6.1. Install matplotlib separately for plotting.

Choose a component

Question Component Guide
What range could contain a numeric outcome? ConformalRegressor Regression
Which class labels remain plausible? ConformalClassifier Classification
How are fitting and calibration managed? BaseConformalPredictor Estimator lifecycle
Are regions useful on unseen data? evaluate and public metrics Diagnostics

Quick start

Wrap the complete pipeline so automatic calibration splits before any learned preprocessing fits. Automatic calibration reserves 20% of rows passed to fit by default; set tts_kwargs={"test_size": 0.25} to change that. Here alpha=0.1 requests 90% marginal coverage:

from sklearn.datasets import make_regression
from sklearn.linear_model import Ridge
from sklearn.model_selection import train_test_split
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler

from conformity import ConformalRegressor

X, y = make_regression(n_samples=1000, n_features=5, noise=15, random_state=7)
X_dev, X_test, y_dev, y_test = train_test_split(X, y, test_size=0.25, random_state=8)
model = ConformalRegressor(
    Pipeline([("scaler", StandardScaler()), ("ridge", Ridge())]),
    tts_kwargs={"random_state": 9},
).fit(X_dev, y_dev)

points, intervals = model.predict(X_test, alpha=0.1, return_interval=True)
assert points.shape == (250,)
assert intervals.shape == (250, 2)
print(model.evaluate(X_test, y_test, alpha=0.1))

The report pairs point error with coverage, width and interval score. The default bounds are symmetric and constant-width at a fixed alpha; choose the asymmetric regression method when lower and upper residual corrections should be calibrated separately. Test coverage fluctuates around the population target. The complete walkthrough explains the configuration, results and next steps.

For classification, predict_set returns a boolean membership matrix in fitted classes_ order. predict(..., return_set=True) returns (membership, probabilities). Run the classification example to interpret label sets, empty sets and review decisions.

Guarantees and limitations

Coverage is marginal under exchangeability, with fitting and model selection independent of final calibration. It does not guarantee coverage for each individual or subgroup. Distribution shift, time dependence and calibration leakage can invalidate the guarantee. Very small calibration sets can require infinite intervals or all-class sets.

Regression supports one numeric target with symmetric absolute-residual or asymmetric signed-residual intervals. Classification supports LAC and deterministic APS scores and requires valid predict_proba output. Calibration is unweighted; weights affect fitting or evaluation only.

Read calibration and assumptions and the theory guide before making decisions from uncertainty output.

Documentation

The documentation site covers installation, plotting, guides, estimator classes, diagnostics, runnable examples, generated API reference and development. It becomes available after the first successful Pages deployment.

Start with getting started, then examples. The original README workflows, existing API guide, and theory are preserved in full.

Development

Use the locked checkout environment and run bash scripts/validate.sh. See development for setup, documentation preview, reference regeneration, example validation, tests, linting and local distribution builds.

Metadata

Release files for conformity-calib 0.1.10

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

Source distribution (sdist)

Source distribution for conformity-calib 0.1.10
File Size Uploaded
conformity_calib-0.1.10.tar.gz 557.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for conformity-calib 0.1.10
File Interpreter ABI Platform
conformity_calib-0.1.10-py3-none-any.whl Python 3 none any Details

Total release size: 578.7 kB

Release files / conformity_calib-0.1.10.tar.gz

Download URL conformity_calib-0.1.10.tar.gz
Size 557.7 kB
Tags Source
SHA-256 checksum
How to use checksums
6ab1ad65a4d4a0de4473027144e7a8e4e9d21637818b1c2249d461e710ec6be3
BLAKE2b-256 checksum
How to use checksums
d5ac3a89ff81f38472b75dadf4bee767cafb794db3b830e37d08a9db20cfd494
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 13, 2026.

Transparency log

Release files / conformity_calib-0.1.10-py3-none-any.whl

Download URL conformity_calib-0.1.10-py3-none-any.whl
Size 20.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3cd110a386255b09479593d9d70494f6123d8b99e3912b76babca00c40ceae99
BLAKE2b-256 checksum
How to use checksums
3cd481416b6dc4f302f6c295d62932977a67b33fe8924a1e4a0952bf2d8b5cf3
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 13, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.10 This release

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.5

2 release files

0.1.2

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