Metadata-Version: 2.5
Name: pyconformal
Version: 0.0.1
Summary: Conformal prediction for Python: distribution-free prediction intervals and prediction sets with finite-sample coverage guarantees.
Project-URL: Homepage, https://github.com/valeman/pyconformal
Project-URL: Source, https://github.com/valeman/pyconformal
Project-URL: Issues, https://github.com/valeman/pyconformal/issues
Author-email: Valery Manokhin <val@valeriy.ai>
License-Expression: MIT
License-File: LICENSE
Keywords: calibration,conformal prediction,machine learning,prediction intervals,prediction sets,uncertainty quantification
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Scientific/Engineering :: Mathematics
Requires-Python: >=3.9
Requires-Dist: numpy>=1.22
Provides-Extra: test
Requires-Dist: pytest>=7; extra == 'test'
Requires-Dist: scikit-learn>=1.0; extra == 'test'
Description-Content-Type: text/markdown

# pyconformal

Conformal prediction for Python: prediction intervals and prediction sets with
finite-sample coverage guarantees, for any model.

> **Status: early development (0.0.1).** The API will change before 1.0.

## Install

```bash
pip install pyconformal
```

## Regression: prediction intervals

```python
from sklearn.ensemble import RandomForestRegressor
from pyconformal import SplitConformalRegressor

model = SplitConformalRegressor(RandomForestRegressor(), alpha=0.1)
model.fit(X_train, y_train)        # train the model
model.calibrate(X_cal, y_cal)      # held-out calibration data
intervals = model.predict_interval(X_test)   # shape (n, 2): lower, upper
```

## Classification: prediction sets

```python
from sklearn.linear_model import LogisticRegression
from pyconformal import SplitConformalClassifier

model = SplitConformalClassifier(LogisticRegression(), alpha=0.1)
model.fit(X_train, y_train)
model.calibrate(X_cal, y_cal)
sets = model.predict_set(X_test)   # boolean (n, n_classes), columns = model.classes_
```

Already have a trained model? Pass `prefit=True` and skip `fit`.

## The guarantee

If the calibration data and the test point are exchangeable (for example,
i.i.d.), the interval or set contains the true value with probability at least
`1 - alpha`. The guarantee is marginal (on average over test points), not
conditional on each input. It holds for any model and any data distribution.

The calibration data must not be used to train the model. If the calibration
set is too small for the chosen `alpha` (fewer than `1/alpha - 1` points), the
intervals are infinite, which is the only way to keep the guarantee.

## Licence

MIT. Copyright (c) 2026 Valery Manokhin.
