Package parsimony :: Package algorithms :: Module nipals :: Class FastSparseSVD
[hide private]
[frames] | no frames]

Class FastSparseSVD

source code

         object --+        
                  |        
bases.BaseAlgorithm --+    
                      |    
bases.ImplicitAlgorithm --+
                          |
                         FastSparseSVD

Instance Methods [hide private]
 
run(self, X, max_iter=100, start_vector=None)
A kernel SVD implementation for sparse CSR matrices.
source code

Inherited from bases.BaseAlgorithm: get_params, set_params

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Static Methods [hide private]

Inherited from bases.BaseAlgorithm: check_compatibility

Class Variables [hide private]
  __abstractmethods__ = frozenset([])
  _abc_negative_cache_version = 14

Inherited from bases.ImplicitAlgorithm: __metaclass__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

run(self, X, max_iter=100, start_vector=None)

source code 
A kernel SVD implementation for sparse CSR matrices.

This is usually faster than np.linalg.svd when density < 20% and when
M << N or N << M (at least one order of magnitude). When M = N >= 10000
it is faster when the density < 1% and always faster regardless of
density when M = N < 10000.

These are ballpark estimates that may differ on your computer.

Parameters
----------
X : Numpy array. The matrix to decompose.

max_iter : Integer. Maximum allowed number of iterations.

start_vector : BaseStartVector. A start vector generator. Default is
        to use a random start vector.

Returns
-------
v : Numpy array. The right singular vector.

Example
-------
>>> import numpy as np
>>> from parsimony.algorithms.nipals import FastSparseSVD
>>> np.random.seed(0)
>>> X = np.random.random((10,10))
>>> fast_sparse_svd = FastSparseSVD()
>>> fast_sparse_svd.run(X)
array([[ 0.3522974 ],
       [ 0.35647707],
       [ 0.35190103],
       [ 0.34715338],
       [ 0.19594198],
       [ 0.24103104],
       [ 0.25578904],
       [ 0.29501092],
       [ 0.42311297],
       [ 0.27656382]])

Overrides: bases.ImplicitAlgorithm.run