Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fitting a LassoModel with a particular choice of lambda #49

Open
barankarakus opened this issue Aug 17, 2020 · 9 comments
Open

Fitting a LassoModel with a particular choice of lambda #49

barankarakus opened this issue Aug 17, 2020 · 9 comments

Comments

@barankarakus
Copy link
Contributor

barankarakus commented Aug 17, 2020

It seems to me that the Lasso model-fitting API is not designed for the user to simply pick a particular choice of lambda and fit a model with that particular choice. Having looked at the source code I can see that the way to do this would be to fit a LassoPath and specify the chosen lambda value as a vector containing only that value. This is a bit clunky: I only want to fit one model yet I'm using the LassoPath API.

I suggest having a fit(LassoModel, some stuff; \lambda) method which allows to do this. It should fit a LassoPath only at the chosen lambda value, then construct the LassoModel object from this. We could also give it a default value of 1.0, like sklearn, so that the user can just run fit(LassoModel, X, y) to quickly fit a 'default' lasso model.

Maintainers of this project: If you give me the green light, I can go ahead and submit a PR.

@AsafManela
Copy link
Collaborator

This sounds reasonable from the user's perspective, but I'm not sure the coordinate descent algorithm will work properly in that case. Does glmnet in R or any other package provide this option so you could test against?

@barankarakus
Copy link
Contributor Author

barankarakus commented Aug 18, 2020 via email

@AsafManela
Copy link
Collaborator

It works by starting from a null model (high lambda) then gradually decreasing it with small changes to coefficients. I'm just not sure how it would work if you solved directly for a specific lambda, though the API currently seems to support it.
I suggest you first experiment a bit with providing a vector with a single lambda and see what it does and how it compares with what sklearn gives in that case. It's been a while since I looked at this code carefully, so it may just work.

@barankarakus
Copy link
Contributor Author

barankarakus commented Aug 18, 2020 via email

@AsafManela
Copy link
Collaborator

Sounds good.
There may also be a way to use the select option to get what you want too, by implementing a segment selector (SegSelect) for that single lambda. Its segselect() would just give 1 always. This may or may not be simpler.

@barankarakus
Copy link
Contributor Author

barankarakus commented Aug 18, 2020 via email

@BigBen-L
Copy link

BigBen-L commented Aug 18, 2020 via email

@barankarakus
Copy link
Contributor Author

barankarakus commented Aug 18, 2020 via email

@GabrielPonte
Copy link

do you have any updates related to this? thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants