scikit-learn-contrib/MAPIE

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

What it solves

Machine learning models often make predictions without any indication of how confident they are. This makes it hard to trust them in high-stakes settings like medical diagnosis, finance, or autonomous systems. MAPIE addresses this by providing a way to attach rigorous, statistical guarantees to predictions—like a range of likely values for a regression, or a set of likely classes for a classification—without requiring you to change your underlying model.

How it works

MAPIE uses techniques from conformal prediction and distribution-free inference. Instead of assuming a specific data distribution, it works by holding out a small “conformalization” dataset after training. It then measures how well the model performs on that dataset, and uses that information to wrap the model’s outputs in prediction intervals (for regression) or prediction sets (for classification). The method is model-agnostic: it works with any scikit-learn, TensorFlow, or PyTorch model, because it only needs to see the model’s predictions and true outcomes on the conformalization set. It also supports risk control for more complex tasks like multi-label classification or semantic segmentation, where you can guarantee performance metrics like recall or precision. Recent versions also include exchangeability tests and adaptive methods, and the library has been extended to handle LLM-as-Judge applications.

Who it’s for

MAPIE is useful for data scientists and machine learning engineers who need to quantify uncertainty in production systems, especially when regulatory or safety requirements demand probabilistic guarantees. It is also valuable for researchers working on conformal prediction, and for teams using a wide variety of frameworks (scikit-learn, TensorFlow, PyTorch) because it integrates directly with scikit-learn’s API. The library is open-source and part of the scikit-learn-contrib ecosystem, so it fits well into existing Python data science workflows.

Highlights

  • Model-agnostic: works with scikit-learn, TensorFlow, and PyTorch models.
  • Provides prediction intervals for regression, prediction sets for classification, and risk control for multi-label classification and segmentation.
  • Implements peer-reviewed algorithms with theoretical guarantees under minimal assumptions.
  • Includes exchangeability tests and adaptive conformal prediction methods.
  • Actively maintained, with recent updates for LLM-as-Judge and image segmentation (2026 roadmap).

Related

  • Project
  • Project
  • Project
  • Project
  • Project