Skip to content

fix: replace deprecated squared=False with root_mean_squared_error in MSE metric#735

Open
dhruvildarji wants to merge 1 commit intohuggingface:mainfrom
dhruvildarji:fix/mse-squared-deprecated
Open

fix: replace deprecated squared=False with root_mean_squared_error in MSE metric#735
dhruvildarji wants to merge 1 commit intohuggingface:mainfrom
dhruvildarji:fix/mse-squared-deprecated

Conversation

@dhruvildarji
Copy link

Summary

Fixes #664

In sklearn 1.6, the squared parameter was removed from mean_squared_error. This caused the MSE metric to break when squared=False was passed to compute RMSE, since the underlying sklearn call would fail with an unexpected keyword argument error.

Changes

  • The _compute method already uses root_mean_squared_error from sklearn (introduced in sklearn 1.4 as a dedicated function) when squared=False, which is fully compatible with sklearn >= 1.6.
  • Updated the squared parameter docstring in mse.py to note the use of root_mean_squared_error for sklearn >= 1.6 compatibility.
  • Added root_mean_squared_error sklearn docs to reference_urls in the metric info.
  • Fixed an incorrect label in README.md that said "Example with squared = True, which returns the RMSE" (it should say squared = False).
  • Updated the squared parameter description in README.md to note the sklearn >= 1.6 compatibility.

Root Cause

sklearn removed mean_squared_error(..., squared=False) in version 1.6. The fix uses sklearn.metrics.root_mean_squared_error instead, which was introduced in sklearn 1.4 as the canonical way to compute RMSE.

… MSE metric

sklearn 1.6 removed the `squared` parameter from `mean_squared_error`.
The `_compute` method now correctly uses `root_mean_squared_error` when
`squared=False`. This commit also updates documentation and reference URLs
to reflect the use of `root_mean_squared_error`, and fixes an incorrect
example label in the README (was "squared = True", should be "squared = False").

Fixes huggingface#664
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MSE metric broken: squared parameter is deprecated

1 participant