Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/piskvorky/sparsesvd
Python wrapper around SVDLIBC, a fast library for sparse Singular Value Decomposition
https://github.com/piskvorky/sparsesvd
Last synced: 12 days ago
JSON representation
Python wrapper around SVDLIBC, a fast library for sparse Singular Value Decomposition
- Host: GitHub
- URL: https://github.com/piskvorky/sparsesvd
- Owner: piskvorky
- Created: 2011-11-06T22:25:49.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2013-08-16T13:33:53.000Z (about 11 years ago)
- Last Synced: 2024-10-14T13:07:03.588Z (26 days ago)
- Language: C
- Homepage:
- Size: 290 KB
- Stars: 55
- Watchers: 8
- Forks: 18
- Open Issues: 4
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG.txt
Awesome Lists containing this project
- awesome-topic-models - sparsesvd - Python wrapper for SVDlibc (Models / Truncated Singular Value Decomposition (SVD) / Latent Semantic Analysis (LSA) / Latent Semantic Indexing (LSI))
README
=================================================
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 sparsesvdIn case of problems, see ``_ 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 installThis 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 `_.