Skip to content

Commit bd7b21d

Browse files
MTN: split metrics into 3 modules (regression, classification, calibration). Update doc accordingly (#633)
1 parent 25b275e commit bd7b21d

Some content is hidden

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

41 files changed

+1836
-1730
lines changed

doc/api.rst

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -52,36 +52,54 @@ Calibration
5252

5353
mapie.calibration.MapieCalibrator
5454

55-
Metrics
56-
=======
55+
Calibration Metrics
56+
======================================
5757

5858
.. autosummary::
5959
:toctree: generated/
6060
:template: function.rst
6161

62-
mapie.metrics.classification_coverage_score
63-
mapie.metrics.classification_coverage_score_v2
64-
mapie.metrics.classification_mean_width_score
65-
mapie.metrics.classification_ssc
66-
mapie.metrics.classification_ssc_score
67-
mapie.metrics.cumulative_differences
68-
mapie.metrics.expected_calibration_error
69-
mapie.metrics.hsic
70-
mapie.metrics.kolmogorov_smirnov_cdf
71-
mapie.metrics.kolmogorov_smirnov_p_value
72-
mapie.metrics.kolmogorov_smirnov_statistic
73-
mapie.metrics.kuiper_cdf
74-
mapie.metrics.kuiper_p_value
75-
mapie.metrics.kuiper_statistic
76-
mapie.metrics.length_scale
77-
mapie.metrics.regression_coverage_score
78-
mapie.metrics.regression_coverage_score_v2
79-
mapie.metrics.regression_mean_width_score
80-
mapie.metrics.regression_ssc
81-
mapie.metrics.regression_ssc_score
82-
mapie.metrics.spiegelhalter_p_value
83-
mapie.metrics.spiegelhalter_statistic
84-
mapie.metrics.top_label_ece
62+
mapie.metrics.calibration.expected_calibration_error
63+
mapie.metrics.calibration.top_label_ece
64+
mapie.metrics.calibration.cumulative_differences
65+
mapie.metrics.calibration.kolmogorov_smirnov_cdf
66+
mapie.metrics.calibration.kolmogorov_smirnov_p_value
67+
mapie.metrics.calibration.kolmogorov_smirnov_statistic
68+
mapie.metrics.calibration.kuiper_cdf
69+
mapie.metrics.calibration.kuiper_p_value
70+
mapie.metrics.calibration.kuiper_statistic
71+
mapie.metrics.calibration.length_scale
72+
mapie.metrics.calibration.spiegelhalter_p_value
73+
mapie.metrics.calibration.spiegelhalter_statistic
74+
75+
Classification Metrics
76+
========================================
77+
78+
.. autosummary::
79+
:toctree: generated/
80+
:template: function.rst
81+
82+
mapie.metrics.classification.classification_coverage_score
83+
mapie.metrics.classification.classification_coverage_score_v2
84+
mapie.metrics.classification.classification_mean_width_score
85+
mapie.metrics.classification.classification_ssc
86+
mapie.metrics.classification.classification_ssc_score
87+
88+
Regression Metrics
89+
====================================
90+
91+
.. autosummary::
92+
:toctree: generated/
93+
:template: function.rst
94+
95+
mapie.metrics.regression.regression_coverage_score
96+
mapie.metrics.regression.regression_coverage_score_v2
97+
mapie.metrics.regression.regression_mean_width_score
98+
mapie.metrics.regression.regression_ssc
99+
mapie.metrics.regression.regression_ssc_score
100+
mapie.metrics.regression.hsic
101+
mapie.metrics.regression.coverage_width_based
102+
mapie.metrics.regression.regression_mwi_score
85103

86104
Utils (from mapie_v1)
87105
==============================

doc/quick_start.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Here, we generate one-dimensional noisy data that we fit with a linear model.
6969

7070
# You can compute the coverage of your prediction intervals.
7171

72-
from mapie.metrics import regression_coverage_score_v2
72+
from mapie.metrics.regression import regression_coverage_score_v2
7373

7474
coverage_scores = regression_coverage_score_v2(y_test, y_pred_intervals)
7575

examples/calibration/1-quickstart/plot_calibration_hypothesis_testing.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@
3030
from sklearn.utils import check_random_state
3131

3232
from numpy.typing import NDArray
33-
from mapie.metrics import (cumulative_differences, kolmogorov_smirnov_p_value,
34-
length_scale)
33+
from mapie.metrics.calibration import (
34+
cumulative_differences, kolmogorov_smirnov_p_value,
35+
length_scale,
36+
)
3537

3638
####################################################################
3739
# 1. Create 1-dimensional dataset and scores to test for calibration

examples/calibration/2-advanced-analysis/plot_asymptotic_convergence_of_p_values.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
from sklearn.utils import check_random_state
4141

4242
from numpy.typing import NDArray
43-
from mapie.metrics import (kolmogorov_smirnov_p_value, kuiper_p_value,
44-
spiegelhalter_p_value)
43+
from mapie.metrics.calibration import (spiegelhalter_p_value)
44+
from mapie.metrics.calibration import kolmogorov_smirnov_p_value, kuiper_p_value
4545

4646
##############################################################################
4747
# First we need to generate scores that are perfecty calibrated. To do so,

examples/classification/1-quickstart/plot_comp_methods_on_2d_dataset.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@
5555

5656
from numpy.typing import NDArray
5757
from mapie.classification import MapieClassifier
58-
from mapie.metrics import (classification_coverage_score,
59-
classification_mean_width_score)
58+
from mapie.metrics.classification import (
59+
classification_coverage_score,
60+
classification_mean_width_score,
61+
)
6062

6163
centers = [(0, 3.5), (-2, 0), (2, 0)]
6264
covs = [np.eye(2), np.eye(2) * 2, np.diag([5, 1])]

examples/classification/4-tutorials/plot_crossconformal.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@
3737

3838
from numpy.typing import NDArray
3939
from mapie.classification import MapieClassifier
40-
from mapie.metrics import (classification_coverage_score,
41-
classification_mean_width_score)
40+
from mapie.metrics.classification import (
41+
classification_coverage_score,
42+
classification_mean_width_score,
43+
)
4244

4345
##############################################################################
4446
# 1. Estimating the impact of train/calibration split on the prediction sets

examples/classification/4-tutorials/plot_main-tutorial-binary-classification.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@
3535

3636
from numpy.typing import NDArray
3737
from mapie.classification import MapieClassifier
38-
from mapie.metrics import (classification_coverage_score,
39-
classification_mean_width_score)
38+
from mapie.metrics.classification import (
39+
classification_coverage_score,
40+
classification_mean_width_score,
41+
)
4042

4143
##############################################################################
4244
# 1. Conformal Prediction method using the softmax score of the true label

examples/classification/4-tutorials/plot_main-tutorial-classification.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@
2323
from sklearn.naive_bayes import GaussianNB
2424

2525
from mapie.classification import MapieClassifier
26-
from mapie.metrics import (classification_coverage_score,
27-
classification_mean_width_score)
26+
from mapie.metrics.classification import (
27+
classification_coverage_score,
28+
classification_mean_width_score,
29+
)
2830

2931
##############################################################################
3032
# 1. Conformal Prediction method using the softmax score of the true label

examples/mondrian/1-quickstart/plot_main-tutorial-mondrian-regression.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from sklearn.model_selection import train_test_split
2727
from sklearn.ensemble import RandomForestRegressor
2828

29-
from mapie.metrics import regression_coverage_score_v2
29+
from mapie.metrics.regression import regression_coverage_score_v2
3030
from mapie.mondrian import MondrianCP
3131
from mapie.regression import MapieRegressor
3232

examples/regression/1-quickstart/plot_compare_conformity_scores.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
from sklearn.ensemble import RandomForestRegressor
4343
from sklearn.model_selection import train_test_split
4444

45-
from mapie.metrics import regression_coverage_score
45+
from mapie.metrics.regression import regression_coverage_score
4646
from mapie_v1.regression import CrossConformalRegressor
4747

4848
RANDOM_STATE = 42

0 commit comments

Comments
 (0)