Skip to content

Commit

Permalink
FIX: missing random state
Browse files Browse the repository at this point in the history
  • Loading branch information
Candice Moyet committed Aug 1, 2023
1 parent a96dc70 commit 06fe7b9
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions examples/regression/4-tutorials/plot_cqr_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class :class:`~mapie.subsample.Subsample` (note that the `alpha` parameter is
from mapie.regression import MapieQuantileRegressor, MapieRegressor
from mapie.subsample import Subsample

random_state = 23
random_state = 18
rng = np.random.default_rng(random_state)
round_to = 3

Expand Down Expand Up @@ -135,7 +135,8 @@ class :class:`~mapie.subsample.Subsample` (note that the `alpha` parameter is
n_jobs=-1,
n_iter=100,
cv=KFold(n_splits=5, shuffle=True),
verbose=0
verbose=0,
random_state=random_state
)
optim_model.fit(X_train, y_train)
estimator = optim_model.best_estimator_
Expand Down Expand Up @@ -265,10 +266,14 @@ def plot_prediction_intervals(
for strategy, params in STRATEGIES.items():
if strategy == "cqr":
mapie = MapieQuantileRegressor(estimator, **params)
mapie.fit(X_train, y_train, X_calib=X_calib, y_calib=y_calib)
mapie.fit(
X_train, y_train,
X_calib=X_calib, y_calib=y_calib,
random_state=random_state
)
y_pred[strategy], y_pis[strategy] = mapie.predict(X_test)
else:
mapie = MapieRegressor(estimator, **params)
mapie = MapieRegressor(estimator, **params, random_state=random_state)
mapie.fit(X_train, y_train)
y_pred[strategy], y_pis[strategy] = mapie.predict(X_test, alpha=0.2)
(
Expand Down

0 comments on commit 06fe7b9

Please sign in to comment.