Git Product home page Git Product logo

sparsesvd's Introduction

sparsesvd -- Sparse Singular Value Decomposition

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, Scipy and Cython.

Install sparsesvd and its dependencies with:

pip install numpy
pip install scipy
pip install cython
pip install sparsesvd

In case of problems, see http://www.scipy.org/Download for instructions on installing SciPy on various platforms.

If you have instead downloaded and unzipped the source tar.gz package, run:

python setup.py test
sudo python setup.py install

This version has been tested under Python 2.6 and 3.2, but should run on any later versions of both 2.x and 3.x series.

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 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, Cython and Python 3.x port by Alejandro Pulver. For an application of sparse SVD to Latent Semantic Analysis, see the gensim package.

You can use this code under the simplified BSD license.

sparsesvd's People

Contributors

piskvorky avatar tail avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.