MAPIE: an open-source library for distribution-free uncertainty quantification

Vianney Taquet, Vincent Blot, Thomas Morzadec, Louis Lacombe, Nicolas J.-b. BrunelarXiv 2022 · DOI

Abstract

MAPIE (Model Agnostic Prediction Interval Estimator) is a scikit-learn-compatible Python library that implements rigorous uncertainty quantification (UQ) for machine learning models. By utilizing conformal prediction, MAPIE generates prediction intervals with mathematically guaranteed coverage, independent of the underlying data distribution. This paper outlines the library's methodology, its application to regression, classification, and time-series data, and demonstrates its effectiveness through empirical benchmarks.

Introduction

Modern machine learning models often operate as "black boxes," providing point estimates without associated confidence measures. In critical domains such as medicine, finance, and autonomous systems, the absence of uncertainty quantification poses significant risks. While Bayesian methods and Quantile Regression offer solutions, they frequently rely on specific architectures or distributional assumptions. MAPIE addresses these limitations by providing a distribution-free UQ framework that is model-agnostic, theoretically grounded, and standardized via the scikit-learn API.

Methodology

The foundation of MAPIE is Conformal Prediction (CP), which utilizes "conformity scores" to quantify how well new observations align with training data.

Regression and Time Series

For regression, MAPIE implements data-efficient variations such as Jackknife+, CV+, and Jackknife+-after-Bootstrap. These methods leverage resampling to estimate residuals without requiring a dedicated calibration set. In time-series contexts, where the assumption of exchangeability is violated, MAPIE employs Ensemble Batch Prediction Intervals (EnbPI). EnbPI adapts to "concept drift" by dynamically updating residuals as new data is observed.

Classification

For classification tasks, the library provides methods like LABEL, Adaptive Prediction Sets (APS), and Top-K. These techniques produce prediction sets rather than single labels, ensuring that the true class is included within the set with a user-specified probability.

Experimental Evaluation

The library's performance was evaluated using two primary datasets:

  1. Victoria Electricity Demand: A time-series dataset featuring a simulated "change point" (a 2GW drop) to test adaptive UQ.
  2. CIFAR10: A benchmark image classification dataset used to assess the reliability of prediction sets.

Results and Discussion

Adaptive Time-Series Forecasting

A key strength of MAPIE is its ability to handle non-stationary data. In the electricity demand experiment, the model encountered a sudden regime shift. By updating residuals during inference, MAPIE's EnbPI implementation successfully expanded its prediction intervals to encompass the new data distribution, signaling increased uncertainty to the user.

EnbPI adaptation to a sudden change point in electricity demand via residual updates.

Reliable Classification Sets

On the CIFAR10 dataset, MAPIE's conformal methods achieved the target marginal coverage exactly, contrasting with "naive" softmax-based uncertainty which often proved overconfident. Evaluation of different methods revealed trade-offs between set size and the frequency of empty prediction sets. The APS method was found to be particularly robust, avoiding empty sets while maintaining coverage.

Performance metrics for conformal classification methods on CIFAR10, showing coverage, set sizes, and empty set rates.

Conclusion and Future Work

MAPIE provides a robust, easy-to-use framework for adding rigorous uncertainty quantification to existing machine learning pipelines. While current versions assume constant interval widths (homoscedasticity) and exhibit a slight lag in time-series adaptation, future developments aim to incorporate Conformalized Quantile Regression (CQR) for heteroscedastic noise and extend support to tasks like image segmentation and object detection.

Summary updated

BibTeX
@misc{taquet2022mapie,
  author = {Vianney Taquet and Vincent Blot and Thomas Morzadec and Louis Lacombe and Nicolas J.-B. Brunel},
  title = {{MAPIE: an open-source library for distribution-free uncertainty quantification}},
  year = {2022},
  eprint = {2207.12274},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2207.12274},
}
Figure