-
Notifications
You must be signed in to change notification settings - Fork 5
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
Using ElasticNet from sklearn instead of glmnet #1
Comments
Thanks for the interest. Unfortunately, |
Thanks for your reactivity! I'll keep maintaining a separate conda env with appropriate glmne for sparse-rrr |
Hi @Yves33 . Thank you for your valuable feedback. I wanted to expand on it. I therefore experimented using ElasticNet() anyway from scikit-learn and found it to work quite well, at least for the In fact, @dkobak , are we sure that ElasticNet does not use the group lasso penalty right now? I don't know if it has been updated but when we look at the docs, I'm not sure if there is much difference with the group lasso penalty as how we derive it in the paper. I might fork the repo soon and try to make things work with ElasticNet() instead of glmnet_py . |
Thanks, I am eager to look at the scikit-learn version! |
Hi @ybernaerts! Where is this screenshot from? When I look here https://scikit-learn.org/dev/modules/generated/sklearn.linear_model.ElasticNet.html, I don't see any mention of multi-task version. However, I now realized that there is this https://scikit-learn.org/dev/modules/generated/sklearn.linear_model.MultiTaskElasticNet.html. |
Hi @dkobak , if you scroll down in your first link (or maybe do Ctrl+F and search for "static path"), you should find my screenshot. But indeed, I assume that when you call ElasticNet() with multivariate y, what actually will be called is MultiTaskElasticNet() (your second link) as the loss functions in both cases are the same. |
Hmm. I don't think so. from sklearn.linear_model import ElasticNet, MultiTaskElasticNet
from sklearn.datasets import make_regression
import numpy as np
X, y = make_regression(n_features=20, n_targets=5, random_state=0)
regr = ElasticNet(random_state=0, alpha=20, l1_ratio=0.9)
regr.fit(X, y)
with np.printoptions(precision=3, suppress=True):
print(regr.coef_.T)
print('')
regr = MultiTaskElasticNet(random_state=0, alpha=20, l1_ratio=0.9)
regr.fit(X, y)
with np.printoptions(precision=3, suppress=True):
print(regr.coef_.T) Output:
So my impression is that |
That example is convincing, yet it is confusing I find the same loss objective function in their docs then... |
I now updated my branch to use MultiTaskElasticNet() for demo purposes. So @dkobak , if you think having an extra demo using scikit-learn is useful in this repo, consider the pull request :) |
@ybernaerts Thanks! Merged, and edited your README a little bit. @Yves33 Thanks for raising this issue! |
Hi,
I'm interested in running your rode on my own patch seq datasets.
spare-rrr presently depends on glmnet which is tricky to install with latest scanpy/anndata/numpy/(...), due to compiler version.
from what I understand , glmnet is only used in 3 lines in sparse-RRR.
Would you have any suggestions (or ready to run code) on how to use sklearn elasticnet (https://scikit-learn.org/1.5/modules/linear_model.html#elastic-net) instead of glmnet?
not advanced enough in maths to understand weather both are identical!
Thanks in advance.
The text was updated successfully, but these errors were encountered: