-
-
Notifications
You must be signed in to change notification settings - Fork 25.9k
log_loss giving nan when input is np.float32 and eps is default #24315
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
I traced the behavior from sklearn.metrics.log_loss to np.clip not giving the correct answer for 1-eps, where if the input is numpy array of np.float32, with default eps=1e-15, 1-eps = 1.0, which caused log(1-p) with p=1.0 gives the nan. I initially went to report this to numpy but they say scikit is not supporting array of np.float32 properly. Please see: |
Seems reasonable enough. Would you like to open a PR updating the value to the float32 epsilon (i.e. |
Hi, Can I take this? |
Yes, go ahead :) |
@Micky774 We would face the same issue, if we give a default epsilon of np.finfo(np.float32).eps and the user provides a float16 input. |
Edit: The |
pull request: #24357
The change @Safikh proposed would fix my immediate problem (Thank you!), but...
|
Just mentioning what @ogrisel proposed in one of the PR. It would be better to introduce a |
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
When input has values that are numpy array of np.float32, 1-eps (with default eps=1e-15) results in 1.0, and log_loss() when calculating log(1-p) with p=1.0 results in nan.
Steps/Code to Reproduce
Expected Results
not nan
Actual Results
with eps=1e-15 (default): nan
Versions
The text was updated successfully, but these errors were encountered: