Skip to content

Add train_deviance_path_ to GeneralizedLinearRegressorCV#982

Merged
Matthias Schmidtblaicher (MatthiasSchmidtblaicherQC) merged 14 commits intomainfrom
train-deviance
Mar 23, 2026
Merged

Add train_deviance_path_ to GeneralizedLinearRegressorCV#982
Matthias Schmidtblaicher (MatthiasSchmidtblaicherQC) merged 14 commits intomainfrom
train-deviance

Conversation

@MatthiasSchmidtblaicherQC
Copy link
Copy Markdown
Contributor

Addresses last point on #933 .

GeneralizedLinearRegressorCV now exposes train_deviance_path_ alongside the existing deviance_path_ (validation deviance). This makes it easy to compare training and validation performance across the regularization path.

  • New attribute train_deviance_path_ with shape (n_folds, n_l1_ratios, n_alphas), matching deviance_path_.
  • Computed inside the existing CV loop with negligible overhead (reuses the already-unstandardized coefficients).
  • Saves a reference to x_train before standardization so train deviance is evaluated on the original scale.

Checklist

  • Added a CHANGELOG.rst entry

Expose training-set deviance alongside validation deviance so users can
diagnose over-/under-fitting as regularization changes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

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 extends GeneralizedLinearRegressorCV to expose training-set deviance values along the CV regularization path, enabling direct comparison between training and validation performance across folds, l1_ratios, and alphas.

Changes:

  • Add train_deviance_path_ computed within the existing CV loop in GeneralizedLinearRegressorCV.
  • Add a new test validating the presence and shape of train_deviance_path_.
  • Add a CHANGELOG.rst entry documenting the new attribute.

Reviewed changes

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

File Description
src/glum/_glm_cv.py Computes and stores train_deviance_path_ alongside existing deviance_path_ and updates attribute docs.
tests/glm/test_glm_cv.py Extends solver-equivalence assertions and adds a new test for train_deviance_path_.
CHANGELOG.rst Documents the new train_deviance_path_ feature for the next release.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Compare overall means instead of per-alpha to avoid failures from
unlucky CV splits or high-regularization alphas.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

Suggested changes to better support cross-validation (GeneralizedLinearRegressorCV)

3 participants