Switch calibration.py to Use scipy's expit to Prevent Warnings (#12896)#12909
Merged
rth merged 2 commits intoscikit-learn:masterfrom Jan 3, 2019
ZaydH:fix_issue_12896
Merged
Switch calibration.py to Use scipy's expit to Prevent Warnings (#12896)#12909rth merged 2 commits intoscikit-learn:masterfrom ZaydH:fix_issue_12896
rth merged 2 commits intoscikit-learn:masterfrom
ZaydH:fix_issue_12896
Conversation
…it function instead of directly using np.exp
rth
approved these changes
Jan 3, 2019
Member
rth
left a comment
There was a problem hiding this comment.
LGTM, Thanks @ZaydH!
There is one remaining call to np.exp in calibration.py. The function is also being used to calculate a logistic function in function _sigmoid_calibration (see inner function grad). However an intermediate result is being used elsewhere so I left that unchanged as I was not sure the standard for handling this within sklearn. If you let me know the standard, I can change that too.
I would say we leave it unchanged, given that exp is pretty expensive calculation and it would suboptimal to do this calculation twice when computing the gradient.
qinhanmin2014
approved these changes
Jan 3, 2019
Member
qinhanmin2014
left a comment
There was a problem hiding this comment.
LGTM, thanks @ZaydH , waiting for CI
I think we can change this without tests and what's new
adrinjalali
pushed a commit
to adrinjalali/scikit-learn
that referenced
this pull request
Jan 7, 2019
xhluca
pushed a commit
to xhluca/scikit-learn
that referenced
this pull request
Apr 28, 2019
xhluca
pushed a commit
to xhluca/scikit-learn
that referenced
this pull request
Apr 28, 2019
This reverts commit 0c4d9d3.
xhluca
pushed a commit
to xhluca/scikit-learn
that referenced
this pull request
Apr 28, 2019
This reverts commit 0c4d9d3.
koenvandevelde
pushed a commit
to koenvandevelde/scikit-learn
that referenced
this pull request
Jul 12, 2019
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.
Switch
calibration.pyto Use scipy'sexpitFunction to Prevent Possible Overflow WarningsReference Issues/PRs
Fixes #12896
What does this implement/fix? Explain your changes.
Previously, the logistic function was calculated via calls to
np.exp. This can in some cases lead to warnings due to overflow. This was fixed by changing the calls to scipy'sexpitfunction.Any other comments?
There is one remaining call to
np.expincalibration.py. The function is also being used to calculate a logistic function in function_sigmoid_calibration(see inner functiongrad). However an intermediate result is being used elsewhere so I left that unchanged as I was not sure the standard for handling this withinsklearn. If you let me know the standard, I can change that too.