crepes: a Python Package for Generating Conformal Regressors and Predictive Systems

Henrik BoströmCOPA 2022

Abstract

Standard regression models often fail to quantify uncertainty, providing only point estimates. This paper presents crepes, a lightweight, model-agnostic Python package that implements Conformal Prediction (CP) for regression. crepes enables the generation of statistically valid prediction intervals and full probability distributions through Conformal Predictive Systems (CPS). By supporting advanced features like Mondrian partitioning and out-of-bag calibration, crepes offers a flexible framework for reliable uncertainty quantification in machine learning workflows.

1. Introduction

Most regression models are "overconfident" or, at the very least, silent about their uncertainty. They provide a single number but do not communicate the potential fluctuation of that estimate. Conformal Prediction (CP) addresses this by producing prediction intervals that come with a mathematical guarantee: the true value will fall within the interval at a user-specified probability (e.g., 95%).

While standard CP often produces fixed-width intervals regardless of instance difficulty, the crepes package introduces more sophisticated methods to generate adaptive intervals and full probability distributions, filling a gap in the existing software ecosystem.

2. Methods and Implementation

The crepes package implements several flavors of inductive (split-sample) conformal prediction, allowing users to transform point estimates from any underlying model (e.g., Scikit-learn, XGBoost, PyTorch) into reliable uncertainty measures.

2.1 Conformal Regressors

  • Standard Regressors: Uses a calibration set to find a global margin for point predictions.
  • Normalized Regressors: Adjusts interval widths based on a "difficulty estimate," ensuring wider intervals for harder-to-predict instances.
  • Mondrian Regressors: Partitions data into categories (bins) to ensure the confidence guarantee holds within specific groups, preventing the model from being "right on average" but wrong on specific subpopulations.

2.2 Conformal Predictive Systems (CPS)

Unlike standard regressors that output intervals, CPS outputs a Cumulative Distribution Function (CDF). This allows practitioners to calculate the probability of a value falling below a specific threshold, providing a more granular view of uncertainty.

2.3 Out-of-Bag (OOB) Calibration

For ensemble models like Random Forests, crepes can utilize OOB predictions for calibration. This allows the entire training set to be used for both model training and conformal calibration, maximizing data efficiency.

3. Comparison with Existing Software

crepes distinguishes itself from other libraries by its support for Mondrian partitioning and Conformal Predictive Systems, features often missing in other popular Python and R implementations.

Comparison of `crepes` with other conformal prediction software packages.

As shown in the table above, while packages like MAPIE focus on aggregation methods (like jackknife+), crepes is uniquely positioned to provide both Mondrian partitioning and CPS within the Python ecosystem.

4. Key Results

The package was evaluated using the house_sales dataset from OpenML. The results confirmed the theoretical guarantees of the framework:

  • Coverage: All tested variants achieved the target coverage (e.g., ~95% coverage for a 95% confidence level).
  • Efficiency: Normalized and Mondrian approaches produced smaller median interval sizes by better accounting for instance-specific difficulty.
  • Performance: The package is highly efficient; evaluating 10,000 test instances for a Mondrian OOB CPS took approximately 0.35 seconds on a standard laptop.

5. Conclusion and Future Work

crepes provides a robust and efficient tool for uncertainty quantification in regression. Its model-agnostic design and support for advanced CP variants make it suitable for a wide range of real-world applications. Future development aims to expand the crepes.fillings module with more diverse difficulty estimators and potentially explore transductive CP methods, though the latter presents significant computational challenges.

Summary updated

BibTeX
@inproceedings{bostrom2022crepes,
  author = {Henrik Boström},
  title = {{crepes: a Python Package for Generating Conformal Regressors and Predictive Systems}},
  booktitle = {COPA},
  year = {2022},
}
Figure