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 (memory-efficient).

Installation

In order to install sparsesvd, you’ll need NumPy and Scipy, two Python packages for scientific computing. You can get them from http://www.scipy.org/Download.

The simple way to install sparsesvd is:

sudo easy_install -U sparsesvd

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

python setup.py test
sudo python setup.py install

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

Documentation

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 factors
>>> assert numpy.allclose(mat, numpy.dot(ut.T, numpy.dot(numpy.diag(s), vt)))

Original wrapper by Lubos Kardos, package updated and maintained by Radim Rehurek. For an application of sparse SVD to Latent Semantic Analysis, see the gensim package.

You can use this code under the simplified BSD license.

Project details


Release history Release notifications

History Node

0.2.2

History Node

0.2.1

History Node

0.2.0

History Node

0.1.9

This version
History Node

0.1.8

History Node

0.1.7

History Node

0.1.6

History Node

0.1.5

History Node

0.1.4

History Node

0.1.3

History Node

0.1.2

History Node

0.1.1

History Node

0.1.0

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
sparsesvd-0.1.8.tar.gz (36.8 kB) Copy SHA256 hash SHA256 Source None May 23, 2012

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page