Skip to content

Commit dd39a25

Browse files
Merge pull request #504 from scikit-learn-contrib/493-add-mondrian-cp
493 add mondrian cp
2 parents 603b5da + 12e71f3 commit dd39a25

17 files changed

+1123
-2
lines changed

HISTORY.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ History
55
0.8.x (2024-xx-xx)
66
------------------
77

8+
* Add Mondrian Conformal Prediction for regression and classification
89
* Add `** predict_params` in fit and predict method for Mapie Regression
910
* Update the ts-changepoint notebook with the tutorial
1011
* Change import related to conformity scores into ts-changepoint notebook

doc/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ clean:
5252
-rm -rf examples_classification/
5353
-rm -rf examples_multilabel_classification/
5454
-rm -rf examples_calibration/
55+
-rm -rf examples_mondrian/
5556
-rm -rf generated/*
5657
-rm -rf modules/generated/*
5758

doc/api.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,13 @@ Resampling
108108

109109
subsample.BlockBootstrap
110110
subsample.Subsample
111+
112+
113+
Mondrian
114+
==========
115+
116+
.. autosummary::
117+
:toctree: generated/
118+
:template: class.rst
119+
120+
mondrian.MondrianCP

doc/conf.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,13 +316,15 @@
316316
"../examples/regression",
317317
"../examples/classification",
318318
"../examples/multilabel_classification",
319-
"../examples/calibration"
319+
"../examples/calibration",
320+
"../examples/mondrian",
320321
],
321322
"gallery_dirs": [
322323
"examples_regression",
323324
"examples_classification",
324325
"examples_multilabel_classification",
325-
"examples_calibration"
326+
"examples_calibration",
327+
"examples_mondrian",
326328
],
327329
"doc_module": "mapie",
328330
"backreferences_dir": os.path.join("generated"),

doc/images/mondrian.png

90.5 KB
Loading

doc/index.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@
4949
examples_multilabel_classification/1-quickstart/plot_tutorial_multilabel_classification
5050
notebooks_multilabel_classification
5151

52+
.. toctree::
53+
:maxdepth: 2
54+
:hidden:
55+
:caption: MONDRIAN
56+
57+
theoretical_description_mondrian
58+
examples_mondrian/1-quickstart/plot_main-tutorial-mondrian-regression
59+
5260
.. toctree::
5361
:maxdepth: 2
5462
:hidden:
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
.. title:: Theoretical Description Mondrian : contents
2+
3+
.. _theoretical_description_mondrian:
4+
5+
#######################
6+
Theoretical Description
7+
#######################
8+
9+
Mondrian conformal prediction (MCP) [1] is a method that allows to build prediction sets with a group-conditional
10+
coverage guarantee. The coverage guarantee is given by:
11+
12+
.. math::
13+
P \{Y_{n+1} \in \hat{C}_{n, \alpha}(X_{n+1}) | G_{n+1} = g\} \geq 1 - \alpha
14+
15+
where :math:`G_{n+1}` is the group of the new test point :math:`X_{n+1}` and :math:`g`
16+
is a group in the set of groups :math:`\mathcal{G}`.
17+
18+
MCP can be used with any split conformal predictor and can be particularly useful when one have a prior
19+
knowledge about existing groups wheter the information is directly included in the features
20+
of the data or not.
21+
In a classifcation setting, the groups can be defined as the predicted classes of the data. Doing so,
22+
one can ensure that, for each predicted class, the coverage guarantee is satisfied.
23+
24+
In order to achieve the group-conditional coverage guarantee, MCP simply classifies the data
25+
according to the groups and then applies the split conformal predictor to each group separately.
26+
27+
The quantile of each group is defined as:
28+
29+
.. math::
30+
\widehat{q}^g =Quantile\left(s_1, ..., s_{n^g} ,\frac{\lceil (n^{(g)} + 1)(1-\alpha)\rceil}{n^{(g)}} \right)
31+
32+
Where :math:`s_1, ..., s_{n^g}` are the conformity scores of the training points in group :math:`g` and :math:`n^{(g)}`
33+
is the number of training points in group :math:`g`.
34+
35+
The following figure (from [1]) explains the process of Mondrian conformal prediction:
36+
37+
.. image:: images/mondrian.png
38+
:width: 600
39+
:align: center
40+
41+
References
42+
----------
43+
44+
[1] Vladimir Vovk, David Lindsay, Ilia Nouretdinov, and Alex Gammerman.
45+
Mondrian confidence machine.
46+
Technical report, Royal Holloway University of London, 2003
78.6 KB
Loading
18.8 KB
Loading
36.3 KB
Loading

0 commit comments

Comments
 (0)