Skip to content

fix: support "squared" argument for sklearn>=1.6.1 #662

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions metrics/mse/mse.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"""MSE - Mean Squared Error Metric"""

import datasets
from sklearn.metrics import mean_squared_error
from sklearn.metrics import mean_squared_error, root_mean_squared_error

import evaluate

Expand Down Expand Up @@ -112,8 +112,11 @@ def _get_feature_types(self):

def _compute(self, predictions, references, sample_weight=None, multioutput="uniform_average", squared=True):

mse = mean_squared_error(
references, predictions, sample_weight=sample_weight, multioutput=multioutput, squared=squared
)
if squared:
mse = mean_squared_error(references, predictions, sample_weight=sample_weight, multioutput=multioutput)
else:
mse = root_mean_squared_error(
references, predictions, sample_weight=sample_weight, multioutput=multioutput
)

return {"mse": mse}
2 changes: 1 addition & 1 deletion metrics/mse/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
git+https://github.com/huggingface/evaluate@{COMMIT_PLACEHOLDER}
scikit-learn
scikit-learn>=1.5.2
Copy link
Author

@JohnGiorgi JohnGiorgi Feb 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not seeing root_mean_squared_error in versions earlier than this, hence the new min requirement version