Skip to content

Commit

Permalink
Merge branch 'master' into conformity_with_template_scikitlearn
Browse files Browse the repository at this point in the history
  • Loading branch information
LacombeLouis committed May 13, 2024
2 parents 4180272 + cfbba58 commit 972651f
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 34 deletions.
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ representative at an online or offline event.

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
tcordier@quantmetry.com.
thibault.a.cordier@capgemini.com.
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
Expand Down
51 changes: 26 additions & 25 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
.. -*- mode: rst -*-
|GitHubActions|_ |Codecov|_ |ReadTheDocs|_ |License|_ |PythonVersion|_ |PyPi|_ |Conda|_ |Release|_ |Commits|_ |DOI|_
|GitHubActions| |Codecov| |ReadTheDocs| |License| |PythonVersion| |PyPi| |Conda| |Release| |Commits| |DOI|

.. |GitHubActions| image:: https://github.com/scikit-learn-contrib/MAPIE/actions/workflows/test.yml/badge.svg
.. _GitHubActions: https://github.com/scikit-learn-contrib/MAPIE/actions
:target: https://github.com/scikit-learn-contrib/MAPIE/actions

.. |Codecov| image:: https://codecov.io/gh/scikit-learn-contrib/MAPIE/branch/master/graph/badge.svg?token=F2S6KYH4V1
.. _Codecov: https://codecov.io/gh/scikit-learn-contrib/MAPIE
:target: https://codecov.io/gh/scikit-learn-contrib/MAPIE

.. |ReadTheDocs| image:: https://readthedocs.org/projects/mapie/badge
.. _ReadTheDocs: https://mapie.readthedocs.io/en/latest
.. |ReadTheDocs| image:: https://readthedocs.org/projects/mapie/badge/?version=stable
:target: https://mapie.readthedocs.io/en/stable/?badge=stable
:alt: Documentation Status

.. |License| image:: https://img.shields.io/github/license/simai-ml/MAPIE
.. _License: https://github.com/scikit-learn-contrib/MAPIE/blob/master/LICENSE
:target: https://github.com/scikit-learn-contrib/MAPIE/blob/master/LICENSE

.. |PythonVersion| image:: https://img.shields.io/pypi/pyversions/mapie
.. _PythonVersion: https://pypi.org/project/mapie/
:target: https://pypi.org/project/mapie/

.. |PyPi| image:: https://img.shields.io/pypi/v/mapie
.. _PyPi: https://pypi.org/project/mapie/
:target: https://pypi.org/project/mapie/

.. |Conda| image:: https://img.shields.io/conda/vn/conda-forge/mapie
.. _Conda: https://anaconda.org/conda-forge/mapie
:target: https://anaconda.org/conda-forge/mapie

.. |Release| image:: https://img.shields.io/github/v/release/scikit-learn-contrib/mapie
.. _Release: https://github.com/scikit-learn-contrib/MAPIE/releases
:target: https://github.com/scikit-learn-contrib/MAPIE/releases

.. |Commits| image:: https://img.shields.io/github/commits-since/scikit-learn-contrib/mapie/latest/master
.. _Commits: https://github.com/scikit-learn-contrib/MAPIE/commits/master
:target: https://github.com/scikit-learn-contrib/MAPIE/commits/master

.. |DOI| image:: https://img.shields.io/badge/10.48550/arXiv.2207.12274-B31B1B.svg
.. _DOI: https://arxiv.org/abs/2207.12274
:target: https://arxiv.org/abs/2207.12274

.. image:: https://github.com/simai-ml/MAPIE/raw/master/doc/images/mapie_logo_nobg_cut.png
:width: 400
Expand Down Expand Up @@ -168,27 +169,27 @@ For more information on the contribution process, please go `here <CONTRIBUTING.
MAPIE has been developed through a collaboration between Quantmetry, Michelin, ENS Paris-Saclay,
and with the financial support from Région Ile de France and Confiance.ai.

|Quantmetry|_ |Michelin|_ |ENS|_ |Confiance.ai|_ |IledeFrance|_
|Quantmetry| |Michelin| |ENS| |Confiance.ai| |IledeFrance|

.. |Quantmetry| image:: https://www.quantmetry.com/wp-content/uploads/2020/08/08-Logo-quant-Texte-noir.svg
:width: 150
.. _Quantmetry: https://www.quantmetry.com/
:height: 35
:target: https://www.quantmetry.com/

.. |Michelin| image:: https://www.michelin.com/wp-content/themes/michelin/public/img/michelin-logo-en.svg
:width: 100
.. _Michelin: https://www.michelin.com/en/
.. |Michelin| image:: https://agngnconpm.cloudimg.io/v7/https://dgaddcosprod.blob.core.windows.net/corporate-production/attachments/cls05tqdd9e0o0tkdghwi9m7n-clooe1x0c3k3x0tlu4cxi6dpn-bibendum-salut.full.png
:height: 35
:target: https://www.michelin.com/en/

.. |ENS| image:: https://file.diplomeo-static.com/file/00/00/01/34/13434.svg
:width: 100
.. _ENS: https://ens-paris-saclay.fr/en
:height: 35
:target: https://ens-paris-saclay.fr/en

.. |Confiance.ai| image:: https://pbs.twimg.com/profile_images/1443838558549258264/EvWlv1Vq_400x400.jpg
:width: 100
.. _Confiance.ai: https://www.confiance.ai/
:height: 35
:target: https://www.confiance.ai/

.. |IledeFrance| image:: https://www.iledefrance.fr/themes/custom/portail_idf/logo.svg
:width: 100
.. _IledeFrance: https://www.iledefrance.fr/
.. |IledeFrance| image:: https://www.iledefrance.fr/sites/default/files/logo/2024-02/logoGagnerok.svg
:height: 35
:target: https://www.iledefrance.fr/


🔍 References
Expand Down
2 changes: 1 addition & 1 deletion doc/theoretical_description_binary_classification.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ calibration (see :doc:`theoretical_description_calibration`), confidence interva
These 3 notions are tightly related for score-based classifier, as it is shown in [1].

Prediction sets can be computed in the same way for multiclass and binary classification with
:class:`~mapie.calibration.MapieClassifier`, and there are the same theoretical guarantees.
:class:`~mapie.classification.MapieClassifier`, and there are the same theoretical guarantees.
Nevertheless, prediction sets are often much less informative in the binary case than in the multiclass case.

From Gupta et al [1]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
print(
"Coverage / prediction interval width mean for MapieTimeSeriesRegressor: "
"\nEnbPI without any partial_fit:"
f"{coverage_npfit_enbpi :.3f}, {width_npfit_enbpi:.3f}"
f"{coverage_npfit_enbpi:.3f}, {width_npfit_enbpi:.3f}"
)
print(
"Coverage / prediction interval width mean for MapieTimeSeriesRegressor: "
Expand Down
19 changes: 19 additions & 0 deletions mapie/calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,25 @@ class MapieCalibrator(BaseEstimator, ClassifierMixin):
and multiclass-to-binary reductions." arXiv preprint
arXiv:2107.08353 (2021).
Examples
--------
>>> import numpy as np
>>> from mapie.calibration import MapieCalibrator
>>> X_toy = np.arange(9).reshape(-1, 1)
>>> y_toy = np.stack([0, 0, 1, 0, 1, 2, 1, 2, 2])
>>> mapie = MapieCalibrator().fit(X_toy, y_toy, random_state=20)
>>> y_calib = mapie.predict_proba(X_toy)
>>> print(y_calib)
[[0.84...... nan nan]
[0.75...... nan nan]
[0.62...... nan nan]
[ nan 0.33...... nan]
[ nan 0.33...... nan]
[ nan 0.33...... nan]
[ nan nan 0.33......]
[ nan nan 0.54......]
[ nan nan 0.66......]]
"""

fit_attributes = [
Expand Down
12 changes: 6 additions & 6 deletions mapie/tests/test_calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,9 @@ def test_correct_results(cv: str) -> None:
)
pred_ = mapie_cal.predict_proba(X_test)
top_label_ece_ = top_label_ece(y_test, pred_)
np.testing.assert_array_almost_equal( # type:ignore
results[cv]["y_score"],
pred_,
np.testing.assert_array_almost_equal(
np.array(results[cv]["y_score"]),
np.array(pred_),
decimal=2
)
np.testing.assert_allclose( # type:ignore
Expand Down Expand Up @@ -341,9 +341,9 @@ def test_correct_results_binary(cv: str) -> None:
pred_ = mapie_cal.predict_proba(X_binary)
top_label_ece_ = top_label_ece(y_binary, pred_)
ece = expected_calibration_error(y_binary, pred_)
np.testing.assert_array_almost_equal( # type:ignore
results_binary[cv]["y_score"],
pred_,
np.testing.assert_array_almost_equal(
np.array(results_binary[cv]["y_score"]),
np.array(pred_),
decimal=2
)
np.testing.assert_allclose( # type:ignore
Expand Down

0 comments on commit 972651f

Please sign in to comment.