Test for sklearn compatibility with default parameters#991
Draft
Jan Tilly (jtilly) wants to merge 4 commits intomainfrom
Draft
Test for sklearn compatibility with default parameters#991Jan Tilly (jtilly) wants to merge 4 commits intomainfrom
Jan Tilly (jtilly) wants to merge 4 commits intomainfrom
Conversation
When alpha=0 (no L2 penalty), the closed-form solver previously built normal equations (H = X'WX) and solved them with scipy.linalg.solve. Forming normal equations squares the condition number; for underdetermined systems this caused scipy to return an inaccurate result that differed depending on whether sample weights were supplied as explicit weights or as repeated rows – violating sklearn's check_sample_weight_equivalence contract. Fix: when P2 = 0, solve the equivalent WLS problem directly via lstsq on the sqrt-weighted data matrix (sqrt(W)·X, sqrt(W)·y). This matches the approach used by sklearn.linear_model.LinearRegression, avoids squaring the condition number, and gives a unique minimum-norm solution that is consistent across the two representations. When P2 != 0 the L2 penalty already makes the normal equations well-conditioned, so that path is retained unchanged. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
4653637 to
0cd07ed
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
check_estimator was previously only run with non-default parameters (alpha=1.0 / n_alphas=2), hiding failures that occur with the default constructor. Add a parametrized test that calls check_estimator() with no arguments so CI will catch regressions against sklearn's API.
Checklist
CHANGELOG.rstentry