Add sample_weight to the calculation of alphas in enet_path and LinearModelCV#23045
Add sample_weight to the calculation of alphas in enet_path and LinearModelCV#23045s-banach wants to merge 9 commits intoscikit-learn:mainfrom s-banach:main
Conversation
It seems like this single call to _preprocess_data suffices in all cases.
This tiny example was given in #22914. The test merely asserts that alpha_max is large enough to force the coefficient to 0.
lorentzenchr
left a comment
There was a problem hiding this comment.
A first round of review comments.
As per reviewer's suggestions: (1) Clarify eps=1. (2) Parameterize `fit_intercept`.
(1) Give the name `n_samples` to the quantity `X.shape[0]`. (2) Clarify that `y_offset` and `X_scale` are not used, since these are already applied to the data by `_preprocess_data`.
|
@TomDLT May I kindly ping you as your help would be much appreciated. |
There was a problem hiding this comment.
Looks good, although I did not check the math.
Main remark: The new test function tests that the computed alpha_max is larger or equal to the true alpha_max. To test that they are actually equal, we could test that alpha_max * 0.99 does not return all-zero coefficients.
We could also add a test that the computation still works without sample weights.
I have attempted to update the test according to your recommendation.
My feeling is that |
|
The main thing I'm confused about, is why it's even possible for |
I don't think it guarantees that the
It seems weird indeed. It seems that |
|
Per your suggestion, I parameterized the new test by I know my opinion on this matter isn't very valuable, but I'll share anyway. |
|
I agree it makes more sense to compute the alpha grid within the path function. We would need to have We might still need to have |
|
We won't have time to review this one before the 1.2 release. Moving it to 1.3 |
|
(didn't mean to close :/ ) |
Reference Issues/PRs
Fixes #22914.
What does this implement/fix? Explain your changes.
Modifies
_alpha_gridfunction inlinear_model._coordinate_descentto accept asample_weightargument.The function
_alpha_gridis called in two places,enet_pathandLinearModelCV.The new
sample_weightargument is not used byenet_path, but it is used byLinearModelCV.Any other comments?
Since my previous PR on this issue,
_preprocess_datahas been rewritten.