Skip to content

ENH minor improvement of binomial hessian#28453

Merged
jeremiedbb merged 1 commit intoscikit-learn:mainfrom
lorentzenchr:minor_improvement_binomial_hessian
Feb 20, 2024
Merged

ENH minor improvement of binomial hessian#28453
jeremiedbb merged 1 commit intoscikit-learn:mainfrom
lorentzenchr:minor_improvement_binomial_hessian

Conversation

@lorentzenchr
Copy link
Copy Markdown
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
@github-actions
Copy link
Copy Markdown

✔️ 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
Copy Markdown
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
Copy Markdown
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