Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix do not recommend to increase max_iter in ConvergenceWarning when not appropriate #31316

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 6 commits into from
May 12, 2025

Conversation

ogrisel
Copy link
Member

@ogrisel ogrisel commented May 6, 2025

While investigating #31164 I found out that _check_optimize_result can sometimes lead to misleading error messages.

This fix should help avoid pointing people in a misleading direction when investigating such convergence problems.

Copy link

github-actions bot commented May 6, 2025

✔️ Linting Passed

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

Generated for commit: 0b3f309. Link to the linter CI: here

@ogrisel ogrisel requested a review from Copilot May 6, 2025 15:09
@ogrisel
Copy link
Member Author

ogrisel commented May 6, 2025

For information, I requested a copilot review on this PR to assess its usefulness.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an issue where the convergence warning for the lbfgs solver was misleading by suggesting that users increase the number of iterations even when it isn’t appropriate. The changes update the warning message in _check_optimize_result, update caller invocations in the GLM and newton solver modules, and adjust the corresponding tests to validate the new behavior.

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
sklearn/utils/tests/test_optimize.py Added tests for the updated convergence warning behavior.
sklearn/utils/optimize.py Modified warning message construction based on the max_iter parameter.
sklearn/linear_model/tests/test_logistic.py Updated the expected warning message format in tests.
sklearn/linear_model/_glm/glm.py Passed the max_iter parameter to _check_optimize_result.
sklearn/linear_model/_glm/_newton_solver.py Adjusted the computed max_iter in fallback_lbfgs_solve and its use in _check_optimize_result.
Files not reviewed (1)
  • doc/whats_new/upcoming_changes/changed-models/31316.fix.rst: Language not supported

sklearn/linear_model/_glm/_newton_solver.py Show resolved Hide resolved
sklearn/utils/optimize.py Show resolved Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

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

Minor nit, otherwise LGTM

sklearn/utils/optimize.py Outdated Show resolved Hide resolved
Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
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 8c508c4 into scikit-learn:main May 12, 2025
36 checks passed
@ogrisel ogrisel deleted the fix-_check_optimize_result branch May 12, 2025 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.