fix: replace deprecated squared=False with root_mean_squared_error in MSE metric#735
Open
dhruvildarji wants to merge 1 commit intohuggingface:mainfrom
Open
fix: replace deprecated squared=False with root_mean_squared_error in MSE metric#735dhruvildarji wants to merge 1 commit intohuggingface:mainfrom
dhruvildarji wants to merge 1 commit intohuggingface:mainfrom
Conversation
… 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #664
In sklearn 1.6, the
squaredparameter was removed frommean_squared_error. This caused the MSE metric to break whensquared=Falsewas passed to compute RMSE, since the underlying sklearn call would fail with an unexpected keyword argument error.Changes
_computemethod already usesroot_mean_squared_errorfrom sklearn (introduced in sklearn 1.4 as a dedicated function) whensquared=False, which is fully compatible with sklearn >= 1.6.squaredparameter docstring inmse.pyto note the use ofroot_mean_squared_errorfor sklearn >= 1.6 compatibility.root_mean_squared_errorsklearn docs toreference_urlsin the metric info.README.mdthat said "Example withsquared = True, which returns the RMSE" (it should saysquared = False).squaredparameter description inREADME.mdto note the sklearn >= 1.6 compatibility.Root Cause
sklearn removed
mean_squared_error(..., squared=False)in version 1.6. The fix usessklearn.metrics.root_mean_squared_errorinstead, which was introduced in sklearn 1.4 as the canonical way to compute RMSE.