Search code examples
pythonscikit-learnsvdrapids

Convert cuml (RAPIDS) truncatedSVD into sklearn


I have to convert a code written using cuml (RAPIDS) into sklearn.

I found out that in cuml.truncatedSVD the parameter n_components which is the output dimensions (number of singular values) can equal to the number of inputs/features in cuml, but not in sklearn.decomposition.truncatedSVD which requires a value strictly inferior to the input dimensions.

The cuml code I'm converting takes two features as inputs and computes two singular values, which is impossible with sklearn.

Is there a way workaround or a way to make it work with sklearn?


Solution

  • The solution is to use the SVD methods in scipy (faster in my case) or numpy. You can find more information in this discussion.