Skip to content

Commit 8a82b68

Browse files
committed
Merge branch 'master' into 477-mapieregressor-with-prefit-optimized-model-that-used-training-and-calibration-data
2 parents 13da57f + dd39a25 commit 8a82b68

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+5147
-1667
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ Please describe the tests that you ran to verify your changes. Provide instructi
2222

2323
# Checklist
2424

25-
- [ ] I have read the [contributing guidelines](https://github.com/simai-ml/MAPIE/blob/master/CONTRIBUTING.rst)
26-
- [ ] I have updated the [HISTORY.rst](https://github.com/simai-ml/MAPIE/blob/master/HISTORY.rst) and [AUTHORS.rst](https://github.com/simai-ml/MAPIE/blob/master/AUTHORS.rst) files
25+
- [ ] I have read the [contributing guidelines](https://github.com/scikit-learn-contrib/MAPIE/blob/master/CONTRIBUTING.rst)
26+
- [ ] I have updated the [HISTORY.rst](https://github.com/scikit-learn-contrib/MAPIE/blob/master/HISTORY.rst) and [AUTHORS.rst](https://github.com/scikit-learn-contrib/MAPIE/blob/master/AUTHORS.rst) files
2727
- [ ] Linting passes successfully : `make lint`
2828
- [ ] Typing passes successfully : `make type-check`
2929
- [ ] Unit tests pass successfully : `make tests`

CONTRIBUTING.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ What to work on?
66
----------------
77

88
You are welcome to propose and contribute new ideas.
9-
We encourage you to `open an issue <https://github.com/simai-ml/MAPIE/issues>`_ so that we can align on the work to be done.
9+
We encourage you to `open an issue <https://github.com/scikit-learn-contrib/MAPIE/issues>`so that we can align on the work to be done.
1010
It is generally a good idea to have a quick discussion before opening a pull request that is potentially out-of-scope.
1111

1212
Fork/clone/pull
1313
---------------
1414

1515
The typical workflow for contributing to `mapie` is:
1616

17-
1. Fork the `master` branch from the `GitHub repository <https://github.com/simai-ml/MAPIE>`_.
17+
1. Fork the `master` branch from the `GitHub repository <https://github.com/scikit-learn-contrib/MAPIE>`_.
1818
2. Clone your fork locally.
1919
3. Commit changes.
2020
4. Push the changes to your fork.
@@ -64,8 +64,8 @@ Updating changelog
6464

6565
You can make your contribution visible by :
6666

67-
1. adding your name to the Contributors sections of `AUTHORS.rst <https://github.com/simai-ml/MAPIE/blob/master/AUTHORS.rst>`_
68-
2. adding a line describing your change into `HISTORY.rst <https://github.com/simai-ml/MAPIE/blob/master/HISTORY.rst>`_
67+
1. adding your name to the Contributors sections of `AUTHORS.rst <https://github.com/scikit-learn-contrib/MAPIE/blob/master/AUTHORS.rst>`_
68+
2. adding a line describing your change into `HISTORY.rst <https://github.com/scikit-learn-contrib/MAPIE/blob/master/HISTORY.rst>`_
6969

7070
Testing
7171
-------

HISTORY.rst

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

8+
* Add Mondrian Conformal Prediction for regression and classification
9+
* Add `** predict_params` in fit and predict method for Mapie Regression
10+
* Update the ts-changepoint notebook with the tutorial
11+
* Change import related to conformity scores into ts-changepoint notebook
12+
* Replace `assert np.array_equal` by `np.testing.assert_array_equal` in Mapie unit tests
13+
* Replace `github.com/simai-ml/MAPIE` by `github.com/scikit-learn-contrib/MAPIE`in all Mapie files
14+
* Extend `ConformityScore` to support regression (with `BaseRegressionScore`) and to support classification (with `BaseClassificationScore`)
15+
* Extend `EnsembleEstimator` to support regression (with `EnsembleRegressor`) and to support classification (with `EnsembleClassifier`)
16+
* Refactor `MapieClassifier` by separating the handling of the `MapieClassifier` estimator into a new class called `EnsembleClassifier`
17+
* Refactor `MapieClassifier` by separating the handling of the `MapieClassifier` conformity score into a new class called `BaseClassificationScore`
18+
* Add severals non-conformity scores for classification (`LAC`, `APS`, `RAPS`, `TopK`) based on `BaseClassificationScore`
19+
* Transfer the logic of classification methods into the non-conformity score classes (`LAC`, `APS`, `RAPS`, `TopK`)
20+
* Extend the classification strategy definition by supporting `method` and `conformity_score` attributes
821
* Building unit tests for different `Subsample` and `BlockBooststrap` instances
922
* Change the sign of C_k in the `Kolmogorov-Smirnov` test documentation
1023
* Building a training set with a fraction between 0 and 1 with `n_samples` attribute when using `split` method from `Subsample` class.

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: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,32 @@ Metrics
7373
metrics.spiegelhalter_statistic
7474
metrics.top_label_ece
7575

76-
Conformity scores
77-
=================
76+
Conformity scores (regression)
77+
==============================
7878

7979
.. autosummary::
8080
:toctree: generated/
8181
:template: class.rst
8282

83+
conformity_scores.BaseRegressionScore
8384
conformity_scores.AbsoluteConformityScore
8485
conformity_scores.GammaConformityScore
8586
conformity_scores.ResidualNormalisedScore
8687

88+
Conformity scores (classification)
89+
==================================
90+
91+
.. autosummary::
92+
:toctree: generated/
93+
:template: class.rst
94+
95+
conformity_scores.BaseClassificationScore
96+
conformity_scores.NaiveConformityScore
97+
conformity_scores.LACConformityScore
98+
conformity_scores.APSConformityScore
99+
conformity_scores.RAPSConformityScore
100+
conformity_scores.TopKConformityScore
101+
87102
Resampling
88103
==========
89104

@@ -93,3 +108,13 @@ Resampling
93108

94109
subsample.BlockBootstrap
95110
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

0 commit comments

Comments
 (0)