Skip to main content

Python module that wraps SVDLIBC, a library for sparse Singular Value Decomposition.

Project description

sparsesvd is a Python wrapper around the SVDLIBC library by Doug Rohde, which is itself based on Michael Berry’s SVDPACK.

sparsesvd uses SciPy’s sparse CSC (Compressed Sparse Column) matrix format as input to SVD. This is the same format used internally by SVDLIBC, so that no extra data copies need to be made by the Python wrapper.


In order to install sparsesvd, you’ll need NumPy and Scipy, two Python packages for scientific computing. You can get them from <>.

The simple way to install sparsesvd is:

sudo easy_install sparsesvd

Or, if you have instead downloaded and unzipped the source tar.gz package, you’ll need to run:

python test
sudo python install

This version has been tested under Python 2.5 and 2.6, but should run on any 2.5 <= Python < 3.0.


The sparsesvd module offers a single function, sparsesvd, which accepts two parameters. One is a sparse matrix in the scipy.sparse.csc_matrix format, the other is the number of requested factors (an integer).

>>> import numpy, scipy.sparse
>>> from sparsesvd import sparsesvd
>>> mat = numpy.random.rand(200, 100) # create a random matrix
>>> smat = scipy.sparse.csc_matrix(mat) # convert to sparse CSC format
>>> ut, s, vt = sparsesvd(smat, 100) # do SVD, asking for 100 greatest factors
>>> assert numpy.allclose(mat,,, vt)))

Original wrapper by Lubos Kardos, package maintained by Radim Rehurek. For an extension of sparse SVD to very large input (larger than RAM), see the gensim package.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for sparsesvd, version 0.1.4
Filename, size File type Python version Upload date Hashes
Filename, size sparsesvd-0.1.4-py2.5-macosx-10.5-i386.egg (33.8 kB) File type Egg Python version 2.5 Upload date Hashes View
Filename, size sparsesvd-0.1.4.tar.gz (36.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page