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

Support for sparse matrix #125

Open
Alalalalaki opened this issue Oct 4, 2021 · 4 comments
Open

Support for sparse matrix #125

Alalalalaki opened this issue Oct 4, 2021 · 4 comments
Labels
new feature new feature

Comments

@Alalalalaki
Copy link

Alalalalaki commented Oct 4, 2021

Even when I set both prediction functions to be lasso, which should support for sparse matrix in sklearn, the doubleml pkg throws the error that sparse matrix is not supported. Transforming the matrix to dense format will explode my memory. Is there any particular reason that sparse matrix cannot be used?

@MalteKurz
Copy link
Member

Could you please provide the error message and a minimal working example to reproduce the problem.

@Alalalalaki
Copy link
Author

Alalalalaki commented Oct 4, 2021

@MalteKurz

image

image

@MalteKurz
Copy link
Member

It would have been nice to add the code separately from the screenshot. This makes it easier for everyone to work on this feature request and GitHub then also adds this nice copy-paste-buttons 😉.

from doubleml.datasets import make_plr_CCDDHNR2018
from doubleml import DoubleMLData

n_obs = 200
n_vars = 150
alpha = 0.5

(x, y, d) = make_plr_CCDDHNR2018(alpha=alpha, n_obs=n_obs, dim_x=n_vars, return_type='array')

from scipy.sparse import csr_matrix, csc_matrix
x = csc_matrix(x)

from sklearn.base import clone
from sklearn.linear_model import Lasso
learner = Lasso()
ml_m = clone(learner)
ml_g = clone(learner)

obj_dml_data = DoubleMLData.from_arrays(x, y, d)

@MalteKurz MalteKurz added the new feature new feature label Oct 4, 2021
@Alalalalaki
Copy link
Author

@MalteKurz Thanks. Yes, I shouldn't use screenshot for the code.

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

No branches or pull requests

2 participants