-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
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
base: main
Are you sure you want to change the base?
Conversation
For information, I requested a copilot review on this PR to assess its usefulness. |
There was a problem hiding this 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
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.