-
Notifications
You must be signed in to change notification settings - Fork 83
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
Handling sparse matrices #229
Comments
Hi Sam, you are correct that sparse matrix compatibility is not implemented yet. This would be a welcome feature though. |
Yes, when the documentation says "sparse matrix", we mean it's a dense matrix with sparse non-zero entries. I realize how this can be confusing. You are welcome to submit a pull request to handle sparse matrices. |
A few years later but saw this was still open - I wrote a tensor version here https://github.com/sjkoelle/montlake/blob/master/montlake/optimization/gradientgrouplasso.py |
Hi,
I am trying to run a linear model with group lasso regularization and sparse matrix input.
code (x is a sparse matrix, y a vector):
glm = GLM(distr='normal',group = groups)
glm.fit(x, y)
However, I get the following error.
output:
ValueError Traceback (most recent call last)
in ()
2 glm = GLM(distr='normal',group = groups)
----> 3 glm.fit(x, y)
~/anaconda3/envs/py35021518/lib/python3.5/site-packages/pyglmnet/pyglmnet.py in fit(self, X, y)
579 if not isinstance(X, np.ndarray):
580 raise ValueError('Input data should be of type ndarray (got %s).'
--> 581 % type(X))
582
583 n_features = np.float(X.shape[1])
ValueError: Input data should be of type ndarray (got <class 'scipy.sparse.csc.csc_matrix'>).
I tried to find your sparse matrix benchmarking data in the package, but was unable to. I also looked into the source code, and am not sure where the sparse matrix compatibility is implemented. Can you point me in the right direction (either to an example which uses sparse matrices, by correcting the error presumably present in my syntax, or telling me how to adjust the source code)?
Thanks a lot,
Sam
The text was updated successfully, but these errors were encountered: