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.9

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.9
File Size Uploaded
conformity_calib-0.1.9.tar.gz 513.4 kB Details

Built distribution (wheel)

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

Total release size: 533.0 kB

Release files / conformity_calib-0.1.9.tar.gz

Download URL conformity_calib-0.1.9.tar.gz
Size 513.4 kB
Tags Source
SHA-256 checksum
How to use checksums
4bc46a82e0f3a745610e70625bfa0dece80f239c6d96d74c23d9a810be332cc2
BLAKE2b-256 checksum
How to use checksums
dec3ee2882ae3246f144ab133c6f5b30bdfa5470a76f0a56ee9ca0bf04868345
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.9-py3-none-any.whl

Download URL conformity_calib-0.1.9-py3-none-any.whl
Size 19.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
51de490ddf6a5a5bdaa80c73aecac533caf7637b4c68fe7fbd666a57f637a2fb
BLAKE2b-256 checksum
How to use checksums
f63f441064a8f05de9b473725e0476e239e32c4e95b400ece7f30fb9b338e3eb
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

0.1.10

2 release files

This release

0.1.9 This release

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