2014-03-18 19:56 GMT+01:00 Manoj Kumar <manojkumarsivaraj...@gmail.com>:
> Hello,
>
> I am trying to add support for sparse matrices in RandomizedLasso. I'm stuck
> at this line.
>
> swap, nrm2 = linalg.get_blas_funcs(('swap', 'nrm2'), (X,))
>
> When X is sparse. this fails with the following error.
>
> AttributeError, flags not found.
>
> Is this expected behaviour?
>
> Any help would be greatly appreciated.

BLAS functions only work for contiguous (dense) arrays. You will need
scipy sparse equivalent functions to work with CSR or CSC
datastructures. For instance the `nrm2` function could be emulated by:

row_norms = csr_row_norms(X.tocsc())
row_norms **= 2
norm = np.sqrt(np.sum(row_norms))

with csr_row_norms from:

https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/utils/sparsefuncs.pyx

I don't know how to efficiently swap 2 rows of a CSR matrix. Maybe the
algorithm would have to be adapted a bit in the sparse case.

-- 
Olivier

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Scikit-learn-general mailing list
Scikit-learn-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general

Reply via email to