Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ENH minor improvement of binomial hessian #28453

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

Merged

Conversation

lorentzenchr
Copy link
Member

@lorentzenchr lorentzenchr commented Feb 18, 2024

Reference Issues/PRs

#28048

What does this implement/fix? Explain your changes.

First, the formula for the hessian is wrong, but the difference is beyond machine precision.

For raw_prediction <= -37, exp(raw_prediction) <= 8.533047625744066e-17 is tiny.
Correct formula: hessian = exp(raw_prediction) / (1 + exp(raw_prediction))**2
2nd order hessian: hessian = exp(raw_prediction) * (1 - 2 * exp(raw_prediction))
1st order hessian: hessian = exp(raw_prediction)

The 2nd order hessian is wrongly implemented without the factor 2.

Any other comments?

@lorentzenchr lorentzenchr added Quick Review For PRs that are quick to review and removed cython labels Feb 18, 2024
Copy link

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: 9b91276. Link to the linter CI: here

Copy link
Contributor

@OmarManzoor OmarManzoor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @lorentzenchr

@OmarManzoor OmarManzoor added the Waiting for Second Reviewer First reviewer is done, need a second one! label Feb 19, 2024
Copy link
Member

@jeremiedbb jeremiedbb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, second order is irrelevant in this situation since the exp(raw_prediction) < 1e-16 is rounded out anyway in 1 + exp(raw_prediction).

LGTM

@jeremiedbb jeremiedbb merged commit e293ae4 into scikit-learn:main Feb 20, 2024
@lorentzenchr lorentzenchr deleted the minor_improvement_binomial_hessian branch February 20, 2024 18:01
@reshamas reshamas removed the Waiting for Second Reviewer First reviewer is done, need a second one! label Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Quick Review For PRs that are quick to review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants