-
Notifications
You must be signed in to change notification settings - Fork 31
Align ridge alpha path computation with glmnet #972
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
- Compute data-dependent alpha_max for pure ridge (l1_ratio=0) using the null model gradient divided by a small surrogate (0.001), instead of hardcoding alpha_max=10. Falls back to 10 when the gradient is zero (e.g. constant X after centering). - Default min_alpha_ratio is now 1e-2 when n_samples < n_features, matching glmnet's convention. Remains 1e-6 when n_samples >= n_features. - Extend test_alpha_path to cover the pure ridge case (l1_ratio=0). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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 updates how glum builds the regularization (alpha) path for ridge regression to better match glmnet, and adjusts the default path length heuristic based on the n_samples/n_features regime.
Changes:
- Compute a data-dependent
alpha_maxfor pure ridge (l1_ratio=0) based on the null-model gradient (with a0.001surrogate divisor), instead of hardcodingalpha_max=10. - Change the default
min_alpha_ratioto1e-2whenn_samples < n_features(otherwise keep1e-6), matchingglmnet. - Update tests and documentation/changelog to reflect the new alpha-path behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/glum/_glm.py |
Implements ridge alpha_max from null-model gradient; updates default min_alpha_ratio logic and docs. |
src/glum/_glm_cv.py |
Updates CV estimator docs for the new default min_alpha_ratio behavior. |
tests/glm/test_glm_regressor.py |
Extends alpha-path test coverage to include both lasso (l1_ratio=1) and ridge (l1_ratio=0). |
CHANGELOG.rst |
Adds an UNRELEASED entry describing the changed ridge alpha_max and min_alpha_ratio defaults. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Compute data-dependent alpha_max for pure ridge (l1_ratio=0) using the null model gradient divided by a small surrogate (0.001), instead of hardcoding alpha_max=10. Falls back to 10 when the gradient is zero (e.g. constant X after centering). - Default min_alpha_ratio is now 1e-2 when n_samples < n_features, matching glmnet's convention. Remains 1e-6 when n_samples >= n_features. - Extend test_alpha_path to cover the pure ridge case (l1_ratio=0). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Compute data-dependent alpha_max for pure ridge (l1_ratio=0) using the null model gradient divided by a small surrogate (0.001), instead of hardcoding alpha_max=10. Falls back to 10 when the gradient is zero (e.g. constant X after centering). - Default min_alpha_ratio is now 1e-2 when n_samples < n_features, matching glmnet's convention. Remains 1e-6 when n_samples >= n_features. - Extend test_alpha_path to cover the pure ridge case (l1_ratio=0). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Compute data-dependent alpha_max for pure ridge (l1_ratio=0) using the null model gradient divided by a small surrogate (0.001), instead of hardcoding alpha_max=10. Falls back to 10 when the gradient is zero (e.g. constant X after centering). - Default min_alpha_ratio is now 1e-2 when n_samples < n_features, matching glmnet's convention. Remains 1e-6 when n_samples >= n_features. - Extend test_alpha_path to cover the pure ridge case (l1_ratio=0). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Closes #966.
The PR introduces a data dependent alpha grid for ridge regression (which we already have for lasso or elastic net) and aligns the alpha path computation more closely with glmnet:
Checklist
CHANGELOG.rstentry