Repository navigation
FEA Add positive argument to Ridge using L-BFGS-B solver - #20231
Conversation
|
@tnakae Thanks for working on this! I'll try to review. |
|
Could you please add a test that checks that it converge to the same solution with Something like: >>> import numpy as np
>>> rng = np.random.RandomState(42)
>>> X = rng.randn(300, 100)
>>> true_coef = rng.uniform(0.1, 1, size=X.shape[1])
>>> y = X @ true_coef + 1 + rng.normal(X.shape[0]) / 10
>>> from sklearn.linear_model import Ridge
>>> Ridge().fit(X, y).coef_
array([0.8425452 , 0.88417954, 0.48863294, 0.43436882, 0.65071889,
0.1547429 , 0.72064224, 0.80411708, 0.45595553, 0.25229772,
...
0.29870553, 0.10603551, 0.69988191, 0.82548552, 0.33983739]) |
|
@ogrisel Added test based on your comment! |
|
Thanks. I have another test idea: try to fit such a This last point is similar to the idea I suggested in #19615 to use the |
|
Out of curiosity could you also please benchmark the solver on a medium size dataset and compare to the speed of the solvers used for It would also be interesting to see a screenshot of the output of a profiling run with https://pypi.org/project/viztracer/ just to make sure that there is no unexpected performance problem. |
54ccb3f to
45b0aae
Compare
agramfort
left a comment
There was a problem hiding this comment.
@lorentzenchr or @rth final pass?
thx @tnakae !
lorentzenchr
left a comment
There was a problem hiding this comment.
This is good work! Thank you @tnakae
I had only a few comments.
lorentzenchr
left a comment
There was a problem hiding this comment.
One last thing is to test _solve_lbfgs directly against another solver for positive=False.
Added test function |
|
@tnakae Thanks again. This was a pleasant review experience on my side. Looking forward for the next one:smirk: |
FEA Add positive argument to Ridge using L-BFGS-B solver (scikit-learn#20231)
|
great work @tnakae ! |
Reference Issues/PRs
Fixes #19772 (Add positive argument to Ridge regression)
What does this implement/fix? Explain your changes.
lbfgssolver to Ridge regression.L-BFGS-Bsolver is used for constrained optimization.lsq_linearwas proposed In the discussion in issue Add positive argument to Ridge regression #19772,it was found that
lsq_linearwas much slower thanL-BFGS-B.positiveargument to Ridge regression.True, forces the coefficients to be positive (default value isFalse)lbfgssolver is supportedpositive=Trueargument.positive=Trueandsolver="auto",lbfgssolver is automatically used.