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
|