Skip to content

Commit

Permalink
[BUG] fix BaseRegressor.score method failing with `sklearn.metrics …
Browse files Browse the repository at this point in the history
…r2_score got an unexpected keyword argument 'normalize'` (sktime#6019)

#### Reference Issues/PRs
Fixes sktime#6018

#### What does this implement/fix? Explain your changes.
Remove non-existing `normalize` parameter for `r2_score` in
`sktime.regression.base` class : `BaseRegressor` method : `score`.
  • Loading branch information
Cyril-Meyer committed Mar 1, 2024
1 parent ee48256 commit 80001b9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -2590,7 +2590,9 @@
"avatar_url": "https://avatars.githubusercontent.com/u/69190238?v=4",
"profile": "https://cyrilmeyer.eu/",
"contributions": [
"code"
"bug",
"code",
"test"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion sktime/regression/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def score(self, X, y, multioutput="uniform_average") -> float:

self.check_is_fitted()

return r2_score(y, self.predict(X), normalize=True, multioutput=multioutput)
return r2_score(y, self.predict(X), multioutput=multioutput)

def _fit(self, X, y):
"""Fit time series regressor to training data.
Expand Down
6 changes: 6 additions & 0 deletions sktime/regression/tests/test_all_regressors.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ def test_regressor_output(self, estimator_instance, scenario):

# run fit and predict
y_pred = scenario.run(estimator_instance, method_sequence=["fit", "predict"])
# check score
score = estimator_instance.score(X_new, y_pred)
assert np.issubdtype(score.dtype, np.floating)

# check predict
assert isinstance(y_pred, np.ndarray)
Expand All @@ -95,6 +98,9 @@ def test_multioutput(self, estimator_instance):

estimator_instance.fit(X, y_mult)
y_pred = estimator_instance.predict(X)
# check score
score = estimator_instance.score(X, y_mult)
assert np.issubdtype(score.dtype, np.floating)

assert isinstance(y_pred, pd.DataFrame)
assert y_pred.shape == y_mult.shape
Expand Down

0 comments on commit 80001b9

Please sign in to comment.