numpy.linalg.svd function gives the full svd of the input matrix. However I want only the first singular vectors.
I was wondering if there is any function in numpy for that or any other library in python?
numpy.linalg.svd function gives the full svd of the input matrix. However I want only the first singular vectors.
I was wondering if there is any function in numpy for that or any other library in python?
One possibility is sklearn.utils.extmath.randomized_svd
from sklearn.utils.extmath import randomized_svd
U, S, Vt = randomized_svd(X, n_components=1)
In addition to randomized svd, you can run ARPACK on the squared problem, via scipy.sparse.linalg.svds.