Skip to content

Commit

Permalink
REFACTO: in split setting, remove checking NaNs and irrelevant aggreg…
Browse files Browse the repository at this point in the history
…ation to avoid triggering unwanted warnings (#586)

* REFACTO: in split setting, remove checking NaNs and irrelevant aggregation to avoid triggering unwanted warnings
  • Loading branch information
Valentin-Laurent authored Jan 6, 2025
1 parent abfc309 commit d8665e4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
7 changes: 5 additions & 2 deletions mapie/estimator/regressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,12 @@ def predict_calib(
predictions[i], dtype=float
)
self.k_[ind, i] = 1
check_nan_in_aposteriori_prediction(pred_matrix)

y_pred = aggregate_all(self.agg_function, pred_matrix)
if self.use_split_method_:
y_pred = pred_matrix.flatten()
else:
check_nan_in_aposteriori_prediction(pred_matrix)
y_pred = aggregate_all(self.agg_function, pred_matrix)

return y_pred

Expand Down
2 changes: 1 addition & 1 deletion mapie/tests/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ def test_not_enough_resamplings() -> None:
"""
with pytest.warns(UserWarning, match=r"WARNING: at least one point of*"):
mapie_reg = MapieRegressor(
cv=Subsample(n_resamplings=1), agg_function="mean"
cv=Subsample(n_resamplings=2, random_state=0), agg_function="mean"
)
mapie_reg.fit(X, y)

Expand Down
3 changes: 2 additions & 1 deletion mapie/tests/test_time_series_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ def test_not_enough_resamplings() -> None:
match=r"WARNING: at least one point of*"
):
mapie_ts_reg = MapieTimeSeriesRegressor(
cv=BlockBootstrap(n_resamplings=1, n_blocks=1), agg_function="mean"
cv=BlockBootstrap(n_resamplings=2, n_blocks=1, random_state=0),
agg_function="mean"
)
mapie_ts_reg.fit(X, y)

Expand Down

0 comments on commit d8665e4

Please sign in to comment.