Skip to content

FIX divide by zero in line search of GradientBoostingClassifier #28095

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
merged 4 commits into from
Jan 15, 2024

Conversation

lorentzenchr
Copy link
Member

@lorentzenchr lorentzenchr commented Jan 10, 2024

Reference Issues/PRs

This is a fix introduces in #26278 and #27312.

What does this implement/fix? Explain your changes.

This PR fixes a situation where the probability in a line search step of GradientBoostingClassifier reaches exactly 0 or 1 leading to a division by zero.

The first commit adds the test. CI will prove that it failed. After that, a fix will be added.

Any other comments?

@ogrisel #28048 (review)

Would it make sense to include such a case as a public API level non-regression tests?

Yes! I'm convinced now.
@glemaitre @lesteve This might be worth to be included in 1.4.0 or, later, in 1.4.1.

Some history

The check denominator == 0 was introduces in d63f39c.
The check abs(denominator) < 1e-150 was introduces in #7970.
#26278 added _safe_divide which handled denominator == 0 correctly, but not on Pyodide.
#27312 fixed the Pyodide thing, but introduced a RuntimeWarnings.
This PR puts back the abs(denominator) < 1e-150 without warnings.

Copy link

github-actions bot commented Jan 10, 2024

✔️ Linting Passed

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

Generated for commit: 1e712fc. Link to the linter CI: here

@lorentzenchr lorentzenchr added this to the 1.4 milestone Jan 10, 2024
@lorentzenchr
Copy link
Member Author

Note: I did not succeed to find a param setting that triggers this case for loss="exponential".

@glemaitre glemaitre changed the title FIX devide by zero in line search of GradientBoostingClassifier FIX divide by zero in line search of GradientBoostingClassifier Jan 11, 2024
Copy link
Member

@glemaitre glemaitre left a comment

Choose a reason for hiding this comment

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

OK, let's go back to this heuristic then.

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.

LGTM. Thanks

@jeremiedbb jeremiedbb merged commit f3b13e5 into scikit-learn:main Jan 15, 2024
@jeremiedbb jeremiedbb added the To backport PR merged in master that need a backport to a release branch defined based on the milestone. label Jan 15, 2024
@lorentzenchr lorentzenchr deleted the gb_instability branch January 15, 2024 21:37
jeremiedbb pushed a commit to jeremiedbb/scikit-learn that referenced this pull request Jan 17, 2024
glemaitre pushed a commit to glemaitre/scikit-learn that referenced this pull request Feb 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug module:ensemble To backport PR merged in master that need a backport to a release branch defined based on the milestone.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants