Skip to content

Conversation

@MatthiasSchmidtblaicherQC
Copy link
Contributor

@MatthiasSchmidtblaicherQC MatthiasSchmidtblaicherQC commented Feb 8, 2026

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:

  • 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.
  • 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.

Checklist

  • Added a CHANGELOG.rst entry

- 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>
Copy link

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 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_max for pure ridge (l1_ratio=0) based on the null-model gradient (with a 0.001 surrogate divisor), instead of hardcoding alpha_max=10.
  • Change the default min_alpha_ratio to 1e-2 when n_samples < n_features (otherwise keep 1e-6), matching glmnet.
  • 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>
Copy link

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ridge regression coefficients differ between glmnet and glum for identical inputs

1 participant