Sklearn TruncatedSVD is not return n, components

872 Views Asked by At

I fitting an LSA model on TfIdf matrix. My original matrix has

(20, 22096) then I'm applying TruncatedSVD to perform the LSI/Reduction

svd = TruncatedSVD(n_components=200, random_state=42, n_iter=10) svdProfile = svd.fit_transform(profileLSAVectors) print(np.shape(svdProfile)) #result (20, 20)

instead of get (20,200) i'm getting (20, 20)

anyone has any idea about why ....?

1

There are 1 best solutions below

2
Vivek Kumar On

Its the "expected" behaviour in most decomposition procedures in Scikit-learn.

I cannot find this mentioned in documentation of TruncatedSVD, but you can see the documentation for PCA, where its mentioned that:

n_components == min(n_samples, n_features)

You can try posting this on the scikit-learn github issues page to get more clarity.