-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
TST tight tests for GLMs #23619
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
TST tight tests for GLMs #23619
Conversation
I think we should document the change in the internal LBFGS configuration to document the improved convergence and maybe suggest the user to adapt the |
I'll add a changelog entry.
No objections in general. I just don't think it's necessary as our default tol=1e-4 is quite large. |
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.
Overall I like the idea and I am ok to change the default parameters of the lbfgs solver to be stricter to allow more precise convergence when setting low tol
values.
My main concern is the expectations we put behind the use of xfail
in our tests. I think lbfgs has no reason to converge to the minimum norm solution for unpenalized problems. We should therefore not assume that this is a "bug" of lbfgs. See the inline comments for more details.
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.
Assuming CI is green, this LGTM.
Maybe @agramfort would be interested in giving this a second review?
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.
just 2 nitpicks
thx @lorentzenchr
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.
Thank you, @lorentzenchr.
A first pass before getting back on solvers.
I could make the CI work in 3458c39. It passes, but on every setting/system several warnings are triggered. Locally, I do not get any error (and I ran it with |
test_glm_regression test_glm_regression_hstacked_X test_glm_regression_vstacked_X test_glm_regression_unpenalized test_glm_regression_unpenalized_hstacked_X test_glm_regression_unpenalized_vstacked_X test_warm_start
test_glm_regression test_glm_regression_hstacked_X test_glm_regression_vstacked_X test_glm_regression_unpenalized test_glm_regression_unpenalized_hstacked_X test_glm_regression_unpenalized_vstacked_X test_warm_start
This reverts commit 99f4cf9.
In 79ec862 I increased the maximum number of linesearch steps in LBFGS from 40 to 50. This eliminated most convergence warnings:
The following plattforms still have warnings:
Summary: I think this is good to go. |
@jeremiedbb we have a problem with the "[all random seeds]" CI config as can be seen in 4fd1d9b which triggers:
it might the problem described in this recent-ish comment on a very old gist from 2015: https://gist.github.com/khamidou/6b7e8702f8fc0e8dd251?permalink_comment_id=4080170
I am not sure what the non-Python test files could be in our case. Let me try to run "[all random seeds]" without pytest-xdist on this PR. The original problem from 2015 related to execnet 1.2. However nowadays we use execnet 1.9 so the original workaround to pin execnet to 1.1 is probably out of date. |
test_glm_regression test_glm_regression_hstacked_X test_glm_regression_vstacked_X test_glm_regression_unpenalized test_glm_regression_unpenalized_hstacked_X test_glm_regression_unpenalized_vstacked_X test_warm_start
The INTERNALERROR we observed with pytest-xdist seems to go away when running the "all random seeds" tests sequentially (but then everything is very slow). Maybe the problem is related to the very large number of tests we generate when we enable "all random seeds"?
EDIT: the sequential |
I have found the source of the lack of convergence to the minimum norm solution when I am working on a PR to this PR that does not try to use the smart intercept init and simplify the tests accordingly. I think converging to the minimum norm solution is a nice inductive bias we should keep if possible. Edit: done in lorentzenchr#7 |
Since lorentzenchr#7 will require more work, I think we can already merge this PR to This will decrease the diff size for the follow-up PRs on the new newton solvers. |
All green. Maybe @jjerphan might have a short look and hit the merge button? This is 99% tests and the one actual change is in the options of lbfgs which lets it pass the tests. |
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.
LGTM up to minor suggestions. Thank you, @lorentzenchr.
Looking forward to further work on the suite of solvers.
Still LGTM. I will let @ogrisel merge after #23619 (comment) is resolved. |
test_glm_regression_hstacked_X
All green, the xfail was no longer needed. Let's merge. |
@ogrisel Thanks for the polishing at the end. |
Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org>
Reference Issues/PRs
This is similar to #22910, but for GLMs instead of Ridge.
What does this implement/fix? Explain your changes.
Very tight test suite for penalized and unpenalized GLMs.
It also modifies the lbfgs options for better convergence (such that it passes the new tests). I think this does not need a changelog entry, but it modifies the model (it may need more iterations, but produce more precise coefficients).
Any other comments?
Prerequesite for #23314.
Locally, all tests pass with
SKLEARN_TESTS_GLOBAL_RANDOM_SEED="all" pytest -x -Werror sklearn/linear_model/_glm/tests/test_glm.py
.