Skip to content

Commit c419cdd

Browse files
authored
DOC: use train_conf_test_split in regression docstrings example, add it to the api doc, and the "Conformity set" doc section (#632)
1 parent 65bb73b commit c419cdd

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

doc/api.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@ Metrics
8383
mapie.metrics.spiegelhalter_statistic
8484
mapie.metrics.top_label_ece
8585

86+
Utils (from mapie_v1)
87+
==============================
88+
89+
.. autosummary::
90+
:toctree: generated/
91+
:template: function.rst
92+
93+
mapie_v1.utils.train_conformalize_test_split
94+
8695
Conformity Scores (Regression)
8796
==============================
8897

doc/split_cross_conformal.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ In all cases, the training/conformalization process can be broken down as follow
1818
==============================
1919

2020
- Compute conformity scores ("conformalization") on a conformity set not seen by the model during training.
21+
(Use :func:`~mapie_v1.utils.train_conformalize_test_split` to obtain the different sets.)
2122

2223
**MAPIE** then uses the conformity scores to estimate sets associated with the desired coverage on new data with strong theoretical guarantees.
2324

mapie_v1/regression.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,17 @@ class SplitConformalRegressor:
7878
Examples
7979
--------
8080
>>> from mapie_v1.regression import SplitConformalRegressor
81+
>>> from mapie_v1.utils import train_conformalize_test_split
8182
>>> from sklearn.datasets import make_regression
8283
>>> from sklearn.model_selection import train_test_split
8384
>>> from sklearn.linear_model import Ridge
8485
8586
>>> X, y = make_regression(n_samples=500, n_features=2, noise=1.0)
86-
>>> X_train, X_conf_test, y_train, y_conf_test = train_test_split(X, y)
87-
>>> X_conformalize, X_test, y_conformalize, y_test = train_test_split(
88-
... X_conf_test, y_conf_test
87+
>>> (
88+
... X_train, X_conformalize, X_test,
89+
... y_train, y_conformalize, y_test
90+
... ) = train_conformalize_test_split(
91+
... X, y, train_size=0.6, conformalize_size=0.2, test_size=0.2, random_state=1
8992
... )
9093
9194
>>> mapie_regressor = SplitConformalRegressor(
@@ -937,14 +940,17 @@ class ConformalizedQuantileRegressor:
937940
Examples
938941
--------
939942
>>> from mapie_v1.regression import ConformalizedQuantileRegressor
943+
>>> from mapie_v1.utils import train_conformalize_test_split
940944
>>> from sklearn.datasets import make_regression
941945
>>> from sklearn.model_selection import train_test_split
942946
>>> from sklearn.linear_model import QuantileRegressor
943947
944948
>>> X, y = make_regression(n_samples=500, n_features=2, noise=1.0)
945-
>>> X_train, X_conf_test, y_train, y_conf_test = train_test_split(X, y)
946-
>>> X_conformalize, X_test, y_conformalize, y_test = train_test_split(
947-
... X_conf_test, y_conf_test
949+
>>> (
950+
... X_train, X_conformalize, X_test,
951+
... y_train, y_conformalize, y_test
952+
... ) = train_conformalize_test_split(
953+
... X, y, train_size=0.6, conformalize_size=0.2, test_size=0.2, random_state=1
948954
... )
949955
950956
>>> mapie_regressor = ConformalizedQuantileRegressor(

0 commit comments

Comments
 (0)