scikit-learn-contrib/MAPIE

A scikit-learn-compatible library for estimating prediction intervals and controlling risks, based on conformal predictions.

MAPIE – Model‑Agnostic Prediction Interval Estimator

What it is

  • A Python library that adds prediction intervals (for regression) and prediction sets (for classification, time‑series, segmentation, etc.) on top of any existing model.
  • It works with scikit‑learn estimators out‑of‑the‑box and also provides thin wrappers for TensorFlow or PyTorch models, so you can keep using the tools you already know.

Why it matters

  • In many real‑world applications you need not just a point prediction but a reliable sense of how uncertain that prediction is. MAPIE gives statistically‑sound, distribution‑free uncertainty estimates based on conformal prediction and related risk‑control theory.
  • The guarantees hold under very mild assumptions (essentially that the calibration data are exchangeable), making the tool useful across domains—from tabular regression to image segmentation and even emerging LLM‑as‑judge scenarios.

Key features (as described in the README)

  • Prediction intervals / sets for regression, classification, time‑series, multi‑label classification, and semantic segmentation.
  • Risk control: lets you set a target risk (e.g., maximum false‑negative rate) and obtain prediction sets that provably respect that risk.
  • Model‑agnostic: works with any scikit‑learn‑compatible estimator; optional wrappers let you plug in TensorFlow or PyTorch models.
  • Adaptive & exchangeability tests: new 2026 features include methods to test whether the exchangeability assumption holds and adaptive conformal techniques that tighten intervals when possible.
  • Extensive documentation & examples: quick‑start notebooks for regression and classification, plus a full Read‑the‑Docs site.

Typical workflow

  1. Train your model as usual (e.g., LinearRegression, RandomForest, a PyTorch net).
  2. Split a hold‑out “calibration” set that MAPIE will use to estimate uncertainty.
  3. Wrap the trained model with a MAPIE class (MapieRegressor, MapieClassifier, etc.).
  4. Fit the wrapper on the calibration data.
  5. Predict with predict_interval or predict_set to obtain intervals/sets together with the usual point predictions.

Installation

pip install mapie          # or conda install -c conda-forge mapie

Requires Python ≥ 3.9, NumPy ≥ 1.23, scikit‑learn ≥ 1.4.

Community & sustainability

  • Part of the scikit‑learn‑contrib ecosystem, meaning it follows the same open‑source governance and testing standards.
  • Actively maintained (GitHub Actions CI, code coverage badges, regular releases).
  • Backed by academic and industry partners (Capgemini Invent, INRA, Michelin, ENS Paris‑Saclay, etc.) and funded by regional and private research bodies.

When to use MAPIE

  • You need calibrated uncertainty for a model you already have.
  • Your application demands formal risk guarantees (e.g., medical diagnostics, autonomous driving, financial forecasting).
  • You prefer a library that does not assume a specific model family and works with minimal extra code.

Where to learn more

  • Quick‑start notebooks in the docs: regression example, classification example.
  • Full API reference and theoretical background on the Read‑the‑Docs site.
  • Academic papers cited in the README for deeper statistical insight.

TL;DR: MAPIE is a well‑maintained, model‑agnostic Python package that adds statistically rigorous uncertainty quantification to any ML model, using conformal prediction and risk‑control methods. It’s useful whenever you need trustworthy confidence intervals or prediction sets without committing to a specific model architecture.

Related

  • Project
  • Project
  • Project
  • Project
  • Project