-
-
Notifications
You must be signed in to change notification settings - Fork 25.9k
mean_squared_log_error - accepts targets with negative values #9963
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
Comments
or we could change and to an or, right? but I guess the operator precedence is unclear. So PR with regression test welcome. I think your version is more clear. |
* fixes msle when the inputs is negative, resolves #9963 * adding some regression tests for msle metric
…kit-learn#9968) * fixes msle when the inputs is negative, resolves scikit-learn#9963 * adding some regression tests for msle metric
…kit-learn#9968) * fixes msle when the inputs is negative, resolves scikit-learn#9963 * adding some regression tests for msle metric
@amueller we have found that the release 0.22.1 of 3 March https://scikit-learn.org/stable/whats_new/v0.22.html#version-0-22-1 have caused this issue again (running on the same code):
Strangely we have put also a
but it seems it does not work. Is it possible that this issue cam out in a previous minor release. We will check with exact version we are using and report here. [UPDATE]
|
[UPDATE]
so that pip will be forced to install
the code now works not using the 0.22.1. Hope this helps. |
@loretoparisi the post here is referring to a bug where an error was not being raised that should have been raised. You are showing now that this error is correctly raised. Therefore the bug has been fixed. |
Why the raise ValueError happen when (y_true < 0) or (y_pred < 0), while log1p is used which can handle negative number greater than -1? |
Description
I found problem, where mean_squared_log_error() function does not catch error.
Steps/Code to Reproduce
Imagine simple situation, where regression model predicts negative value:
This happened, when my regression model predicted 1 negative value (among thousands of positive values).
Expected correct behavior:
Expected behavior is, that exception:
ValueError("Mean Squared Logarithmic Error cannot be used when targets contain negative values.")
should be raised and correctly inform about the underlying problem.
Exact location, where is the bug
Problematic code is exactly in sklearn/metrics/regression.py: (around line 313)
The condition is not fully correct and evaluates to False for example above - which is wrong.
It should evaluate to True, and raise the exception.
Suggested solution:
Just change the condition to:
so it catches the problem in case any of the y_true or y_pred contain negative value.
The text was updated successfully, but these errors were encountered: