@@ -37,7 +37,7 @@ Let us start with a basic regression problem.
37
37
Here, we generate one-dimensional noisy data that we fit with a linear model.
38
38
39
39
..
40
- Comment to developers: the following piece of code is duplicated in `examples/regression/1-quickstart/plot_toy_model.py`.
40
+ Comment to developers: the following piece of code is heavily inspired by `examples/regression/1-quickstart/plot_toy_model.py`.
41
41
When updating it, please replicate the changes to this other file.
42
42
43
43
.. testcode ::
@@ -46,25 +46,18 @@ Here, we generate one-dimensional noisy data that we fit with a linear model.
46
46
from sklearn.datasets import make_regression
47
47
from sklearn.model_selection import train_test_split
48
48
49
- RANDOM_STATE = 42
50
- X, y = make_regression(n_samples=500, n_features=1, noise=20, random_state=RANDOM_STATE)
51
- X_train_conformalize, X_test, y_train_conformalize, y_test = train_test_split(
52
- X, y, test_size=0.5, random_state=RANDOM_STATE
53
- )
54
- X_train, X_conformalize, y_train, y_conformalize = train_test_split(
55
- X_train_conformalize, y_train_conformalize, test_size=0.5, random_state=RANDOM_STATE
56
- )
49
+ X, y = make_regression(n_samples=500, n_features=1, noise=20)
50
+
51
+ X_train, X_temp, y_train, y_temp = train_test_split(X, y)
52
+ X_test, X_conformalize, y_test, y_conformalize = train_test_split(X_temp, y_temp)
57
53
58
54
# We follow a sequential ``fit ``, ``conformalize ``, and ``predict `` process.
59
55
# We set the confidence level to estimate prediction intervals at approximately one and two
60
56
# standard deviation from the mean.
61
57
62
58
from mapie_v1.regression import SplitConformalRegressor
63
59
64
- mapie_regressor = SplitConformalRegressor(
65
- confidence_level=[0.95, 0.68],
66
- prefit=False,
67
- )
60
+ mapie_regressor = SplitConformalRegressor(confidence_level=[0.95, 0.68], prefit=False)
68
61
mapie_regressor.fit(X_train, y_train)
69
62
mapie_regressor.conformalize(X_conformalize, y_conformalize)
70
63
0 commit comments