scipyscikit-learnsvd

Difference between TruncatedSVD and svds


I see that the documentation for both sklearn.decomposition.TruncatedSVD and scipy.sparse.linalg.svds mention that they both perform SVD for sparse matrices. What is the difference between them?

Thanks.


Solution

  • TruncatedSVD is more feature-rich. It has the scikit-learn API, so you can put it in a sklearn.Pipeline object and call transform on a new matrix instead of having to figure out the matrix multiplications yourself. It offers two algorithms: either a fast randomized SVD solver (the default), or scipy.sparse.svds.

    (Full disclosure: I wrote TruncatedSVD.)