Skip to content

Commit 7d3d811

Browse files
committed
pass extra kwargs from search.score to search.best_learner_.score
1 parent 3039ae4 commit 7d3d811

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

skrub/_data_ops/_estimator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,7 +1268,7 @@ def f(*args, **kwargs):
12681268
f.__name__ = name
12691269
return f
12701270

1271-
def _call_predictor_method(self, name, environment):
1271+
def _call_predictor_method(self, name, environment, **kwargs):
12721272
check_is_fitted(self, "cv_results_")
12731273
if not hasattr(self, "best_learner_"):
12741274
raise AttributeError(
@@ -1277,7 +1277,7 @@ def _call_predictor_method(self, name, environment):
12771277
"Please pass another value to `refit` or fit a learner manually "
12781278
"using the `best_params_` or `cv_results_` attributes."
12791279
)
1280-
return getattr(self.best_learner_, name)(environment)
1280+
return getattr(self.best_learner_, name)(environment, **kwargs)
12811281

12821282
@property
12831283
def results_(self):

skrub/_data_ops/tests/test_estimators.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,10 @@ def test_randomized_search_with_scoring(randomized_search_backend):
585585
search.fit(split["train"])
586586
assert (search.results_["mean_test_neg_brier_score"] <= 0).all()
587587
assert list(search.score(split["test"]).keys()) == ["neg_brier_score", "roc_auc"]
588+
# Test return_predictions is forwarded to best_learner_.score
589+
scores, predictions = search.score(split["test"], return_predictions=True)
590+
assert list(scores.keys()) == ["neg_brier_score", "roc_auc"]
591+
assert predictions["predict_proba"].shape == (split["y_test"].shape[0], 2)
588592

589593

590594
def test_grid_search(data_op, data, n_jobs):

0 commit comments

Comments
 (0)