[scikit-learn] LassoCV.coef not implemented (I think)

Guillaume Lemaître g.lemaitre58 at gmail.com
Sun Jan 31 15:00:34 EST 2021


Hi Robert,

> I do have a .coef_ variable which I believe is the coefficient for the
best fit only.

`coef` never existed. Fitted attributes always end with underscore.
We do not store coefficients for all fitted `alphas_`.
We provide some information regarding the MSE path for all tried alphas:
https://scikit-learn.org/stable/auto_examples/linear_model/plot_lasso_model_selection.html

> the  alphas and alphas_ variables have a similar issue in that alphas
returns nothing while alphas_ returns the list of alphas used.

You probably created a model such as `model = LasssoCV()`. By default, the
parameter `alpha=None` thus accessing it will return None. After fitting,
`alphas_` will be automatically created as specified in the documentation.
It will correspond to the values tried by cross-validation.
If instead, you are passing an array to `alphas` then `alphas_` will be the
same as `alphas_` after calling `fit`.

Cheers,


On Sun, 31 Jan 2021 at 20:45, Robert Slater <rdslater at gmail.com> wrote:

> I was writing an example for my students when I came across what I think
> is an issue.  In version 24.1 using the LassoCV, the <object>.coef variable
> should have a list of my coeficeients (at least according to my
> understanding of the documents).  However, the variable is not populated
> nad throws an error
>
> 'LassoCV' object has no attribute 'coef'
>
>
> I do have a .coef_ variable which I believe is the coefficient for the
> best fit only.
>
> the  alphas and alphas_ variables have a similar issue in that alphas
> returns nothing while alphas_ returns the list of alphas used.
>
> I'm not sure if this is an documentation oversight or a real issue but
> wanted to get clarification.
>
> I can get what I need from o ther methods, but wanted to see if this
> needed to be addressed.
>
> Best Regards,
>
> Robert Slater
> _______________________________________________
> scikit-learn mailing list
> scikit-learn at python.org
> https://mail.python.org/mailman/listinfo/scikit-learn
>


-- 
Guillaume Lemaitre
Scikit-learn @ Inria Foundation
https://glemaitre.github.io/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/scikit-learn/attachments/20210131/6db0c467/attachment.html>


More information about the scikit-learn mailing list