MAPIE v1 release notes¶
Table of Contents
Introduction¶
MAPIE v1’s primary goal is to make the library easier to use, especially for users unfamiliar with conformal predictions. This release consists of an API and documentation revamp, enhancing MAPIE’s clarity and accessibility. Moreover, the new API structure paves the way for efficient development and internal refactoring in the future.
These release notes will help you easily migrate your code to MAPIE v1 and enjoy upcoming new features!
API changes overview¶
The classification and regression APIs have been thoroughly revamped (except for time series). Other API changes (calibration, multi-label classification, time series, etc.) consist mostly of renaming to bring overall consistency and clarity.
Below are the high-level, key changes introduced in MAPIE v1. For details and rationales behind these changes, see the section “API changes in detail”.
Regression and classification classes have been split into more specific classes:
v0.x class |
Corresponding v1 class(es) |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
For classification and regression, the v1
.fit
method is not equivalent to the.fit
method of previous MAPIE versions. It has been split into.fit
and.conformalize
for split conformal techniques, and replaced by.fit_conformalize
for cross-conformal techniques.The
alpha
parameter has been replaced withconfidence_level
(confidence_level
is equivalent to1 - alpha
).
Differences between MAPIE v0.9 and v1.0 on a regression example

⚠️ MAPIE v1 comes with some functional regressions:
The
MondrianCP
class is temporarily unavailable in MAPIE v1. Mondrian can still easily be implemented manually (tutorial provided).In regression settings, the naive method no longer exists for cross conformal techniques. It can still be done manually for split conformal techniques by performing the calibration step on the training set.
Python, scikit-learn and NumPy versions support¶
Requirements have been updated and clarified. We now support:
Python >=3.9, <3.12
NumPy >=1.23
scikit-learn >=1.4
We no longer officially support Python versions between 3.7 and 3.9, and NumPy versions between 1.21 and 1.23. Note that for now, MAPIE still runs using either:
Python <3.9
scikit-learn <1.4, provided SciPy <=1.10
API changes in detail¶
Regression and classification API changes (excluding time series)¶
Classes¶
MAPIE v1 breaks down the MapieRegressor
and MapieClassifier
classes into 5 classes, each dedicated to a particular conformal prediction technique. MapieQuantileRegressor
has also been revamped, and renamed ConformalizedQuantileRegressor
.
The rationale behind this is that MapieRegressor
and MapieClassifier
managed several conformal techniques under a single interface, which led to parameter redundancy and ambiguity. In MAPIE v1, each class includes only the relevant parameters specific to its technique.
The cv
parameter is key to understand what new class to use in the v1 API, in both regression and classification:
Mapie v0.x -> v1 classes correspondence in regression
v0.x class |
|
Corresponding v1 class |
Conformal prediction type |
---|---|---|---|
|
|
|
Split |
|
|
Split |
|
|
|
Cross |
|
|
|
Cross |
Mapie v0.x -> v1 classes correspondence in classification
v0.x class |
|
Corresponding v1 class |
Conformal prediction type |
---|---|---|---|
|
|
|
Split |
|
|
Split |
|
|
|
Cross |
For more details regarding the difference between split and cross conformal types, see The conformalization (or “calibration”) set.
Workflow and methods¶
The conformal prediction workflow has been changed, to clarify the process involved under-the-hood, and to allow a better control on data splitting.
In v0.x, the workflow was:
Data splitting, model training, and calibration, using the
.fit
method with(X, y)
.Interval (or set) prediction, using the
.predict
method with(X_test, y_test)
.
In v1, the workflow is:
Data splitting, left to the user. We provide a new utility
train_conformalize_test_split()
to split data into train, conformalize, and test sets.Model training, using the
.fit
method with(X_train, y_train)
.Model calibration, using the
.conformalize
method with(X_conformalize, y_conformalize)
.Interval (or set) prediction, using the
.predict_interval
/.predict_set
methods with(X_test, y_test)
.
The calibration step has been named conformalization, to avoid confusion with probability calibration, and facilitate usage by users unfamiliar with conformal predictions.
For cross conformal techniques, steps 2 and 3 are performed simultaneously using the .fit_conformalize()
method. Indeed, these techniques rely on fitting and conformalizing models in a cross-validation fashion, thus the steps are not distinct.
MAPIE v1 introduces two new methods for prediction: .predict_interval()
for regression, and .predict_set()
for classification. They return the model prediction and prediction intervals/sets. They thus behave the same way than the .predict(alpha=...)
v0.x method (with some minor output shape changes to keep consistency across all conformal techniques).
The .predict()
method now focuses solely on producing point predictions.
Parameters¶
Regression-specific¶
agg_function
and ensemble
¶
v0.x: Previously, the
agg_function
parameter had two usage: to aggregate predictions when settingensemble=True
in thepredict
method ofMapieRegressor
, and to specify the aggregation used inJackknifeAfterBootstrapRegressor
.v1:
The
agg_function
parameter has been split into two distinct parameters:aggregate_predictions
andaggregation_method
.aggregate_predictions
is specific toCrossConformalRegressor
, and it specifies how predictions from multiple conformal regressors are aggregated when making point predictions.aggregation_method
is specific toJackknifeAfterBootstrapRegressor
, and it specifies the aggregation technique for combining predictions across different bootstrap samples during conformalization.Note that for both cross conformal regression techniques, predictions points are now computed by default using mean aggregation. This is to avoid prediction points outside of prediction intervals in the default setting.
symmetry
¶
v0.x: This parameter of the predict method of
MapieQuantileRegressor
was set to True by defaultv1: This parameter is now named symmetric_correction and is set to False by default, because the resulting intervals are smaller. It is used in the predict_interval method of the ConformalizedQuantileRegressor.
optimize_beta
¶
It has been found during v1 development that this parameter (specific to regression) has never been working as expected (currently does nothing). At v1 release time, the bug hasn’t been fixed yet. See the related GitHub issue.
Note that in v1, this parameter has been renamed minimize_interval_width
for clarity.
Classification-specific¶
include_last_label
¶
Parameter specific to APS or RAPS conformity scores in classification.
v0.x: This parameter is passed to the
predict
method ofMapieClassifier
.v1: This parameter is now passed in a dictionary to the
conformity_score_params
of thepredict_set
method of classification techniques.
size_raps
¶
Parameter specific to the RAPS conformity score in classification.
v0.x: Passing this parameter to the
fit
method ofMapieClassifier
is deprecated.v1: This parameter must now be passed to the
conformity_score
argument at initialization. Ex:SplitConformalClassifier(conformity_score=RAPSConformityScore(size_raps=0.3))
None defaults¶
No more parameters with misleading None
defaults.
v0.x: Eg:
estimator
inMapieRegressor
has aNone
default value, even though the actual default value isLinearRegression()
. This is the case for other parameters as well.v1: All parameters now have explicit defaults.
Other API changes¶
Time series¶
The MapieTimeSeriesRegressor
class has been renamed TimeSeriesRegressor
.
The adapt_conformal_inference
, update
, predict
and coverage_width_based
functions of the class now take confidence_level
as input, instead of alpha
(confidence_level
is equivalent to 1 - alpha
).
The already deprecated path to import the class (from mapie.time_series_regression import TimeSeriesRegressor
) is now unsupported, use path mapie.regression instead.
Risk control¶
The MapieMultiLabelClassifier
class has been renamed PrecisionRecallController
.
The parameter calib_size
from the fit
method has been renamed conformalize_size
.
Calibration¶
The MapieCalibrator
class has been renamed TopLabelCalibrator
.
This class now being specific to top-label calibration, the method
parameter, that was accepting only the value "top-label"
, has been removed.
Mondrian¶
The MondrianCP
class is temporarily unavailable in v1. We want to rethink the way we integrate Mondrian to MAPIE, in a future-proof way.
In the mean time, the Mondrian technique can be easily implemented manually: a tutorial for tabular regression with Mondrian is available in the documentation. This tutorial demonstrates how to implement Mondrian manually (i.e., without using the MondrianCP
class) on a simple regression example, while shedding light on the benefits of this technique.
Metrics¶
In MAPIE v1, metrics are divided into three modules: calibration
, classification
, and regression
, which changes the import paths.
Below is an example of the import needed for the classification_coverage_score
function:
v0.x:
from mapie.metrics import classification_coverage_score
v1:
from mapie.metrics.classification import classification_coverage_score
Additionally, a number of classification and regression functions have been updated from v0.x to v1:
classification_coverage_score
and classification_coverage_score_v2
¶
Now only one version exists (classification_coverage_score
), that corresponds to v0.x classification_coverage_score_v2
.
classification_mean_width
¶
v0.x: Took the prediction sets in an array of shape (n_samples, n_class) for a given confidence level as input, and returned the effective mean width as a float.
v1: Now takes the prediction sets in an array of shape (n_samples, n_class, n_confidence_level) as input, and returns the effective mean width for each confidence level as an array of shape (n_confidence_level,).
regression_coverage_score
and regression_coverage_score_v2
¶
Now only one version exists (regression_coverage_score
), that corresponds to v0.x regression_coverage_score_v2
.
regression_mean_width
¶
v0.x: Took the lower and upper bounds of the prediction intervals in arrays of shape (n_samples,) for a given confidence level as input, and returned the effective mean width as a float.
v1: Now takes a single array of shape (n_samples, 2, n_confidence_level) as input, and returns the effective mean width for each confidence level as an array of shape (n_confidence_level,).
regression_mwi_score
¶
v0.x: Took
alpha
as input.v1: Now takes
confidence_level
as input (confidence_level
is equivalent to1 - alpha
).
coverage_width_based
¶
v0.x: Took
alpha
as input.v1: Now takes
confidence_level
as input (confidence_level
is equivalent to1 - alpha
).
Conformity scores¶
The import of AbsoluteConformityScore
, GammaConformityScore
and ResidualNormalisedScore
from mapie.conformity_scores.residual_conformity_scores
was deprecated and is now unsupported.
You can now import those scores from mapie.conformity_scores.bounds
or simply mapie.conformity_scores
.
The usage of ConformityScore
was deprecated and is now unsupported. The new class to use is BaseRegressionScore
, that can be found in mapie.conformity_scores.regression
.
We may clarify the conformity_scores
package structure in the future.