Inconsistency between coef_ and coef_path_ in LassoLars
See original GitHub issueDescribe the issue linked to the documentation
Hello, the coef_ attribute from LassoLars returns the array of coefficients for the value of alpha given in parameter (1 by default). The coef_path_attribute is described in the doc as follow : “The varying values of the coefficients along the path”. However, the last column of the coef_path_ doesn’t match the values of the coef_ attribute, whereas the alpha value for this column is corresponding to the one given in parameter, hence the values of coefficients should be the same.
For example, if I run :
from sklearn.linear_model import LassoLars
from sklearn.datasets import make_regression
X, y = make_regression(n_samples=50,
n_features=10,
n_informative=3)
lasso = LassoLars().fit(X, y)
coef_ will look like :
array([ 0. , 39.89632517, 77.75976515, 88.68204422, 0. ,
0. , 0. , 0. , 0. , 0. ])
and coef_path_ :
array([[ 0. , 0. , 0. , 0. ],
[ 0. , 0. , 0. , 289.86068748],
[ 0. , 0. , 122.80186215, 573.97268871],
[ 0. , 123.33792921, 246.13979136, 584.906583 ],
[ 0. , 0. , 0. , 0. ],
[ 0. , 0. , 0. , 0. ],
[ 0. , 0. , 0. , 0. ],
[ 0. , 0. , 0. , 0. ],
[ 0. , 0. , 0. , 0. ],
[ 0. , 0. , 0. , 0. ]])
Suggest a potential alternative/fix
Either normalize the 2 attributes in the same way, or give additional information about the coef_path_ values in the doc.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Intuitive explanation for inconsistency between regression and ...
An independent variable in a linear regression I am working on has positive coefficient but this variable has a negative correlation with ...
Read more >coefpath — Plot path of coefficients after lasso - Stata
coefpath graphs the coefficient paths after any lasso fit using selection(cv), selec- tion(adaptive), selection(bic), or selection(none).
Read more >sklearn.linear_model.LassoLars
Only coefficients up to the smallest alpha value ( alphas_[alphas_ > 0.].min() when fit_path=True) reached by the stepwise Lars-Lasso algorithm are ...
Read more >Use variable labels in the coefpath graph after lasso estimation
I am trying to plot the coefficient paths after running a lass command. I am surprised that I cannot seem to find an...
Read more >The Lasso Problem and Uniqueness - Statistics & Data Science
the lasso problem will have many coefficients set exactly to zero, due to the ... Do lasso estimates suffer from the same sign...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you for your answer !
And what do you think of my suggestion to normalize the
coef_path_
attribute as well ? I don’t really see the point keeping the coefficients fromcoef_path_
at a different scale than that at which it has been defined for thecoef__
attribute.The
coef_
is normalized to the scale ofX
:lasso.coef_ * X_scale
gives:which is the last entry of
lasso.coef_path_
. This happens whenfit_intercept=True
. Maybe the documentation could be more clear with this.