Sci-kit Learn TruncatedSVD Explained_variance_ratio_ Not In Descending Order?
This question is actually a duplicate of this one, which however remains unanswered at the time of writing. Why is the explained_variance_ratio_ from TruncatedSVD not in descending
Solution 1:
If you scale the data first, then I think the explained variance ratios will be in descending order:
from sklearn.decomposition import TruncatedSVD
from sklearn.preprocessing import StandardScaler
n_components = 50
X_test = np.random.rand(50,100)
scaler = StandardScaler()
X_test = scaler.fit_transform(X_test)
model = TruncatedSVD(n_components=n_components, algorithm = 'randomized')
model.fit_transform(X_test)
model.explained_variance_ratio_
Post a Comment for "Sci-kit Learn TruncatedSVD Explained_variance_ratio_ Not In Descending Order?"