lundi 16 décembre 2019

sklearn random_state is not working properly

I read everything related to this but still did not understand what the problem is really. Basically I use TruncatedSVD with random_state and then print explained_variance_ratio_.sum() for it. It changes every time I run the code. Is this normal?

from sklearn.decomposition import TruncatedSVD
SVD = TruncatedSVD(n_components=40, n_iter=7, random_state=42)

XSVD = SVD.fit_transform(X)
print(SVD.explained_variance_ratio_.sum())

The problem is later I use umap and plot the result graph. And I have different graphs everytime I run the code. I do not understand if this is due to TruncatedSVD or UMAP. I use random_state=42 to stop things to change but it looks like there is no effect really.




Aucun commentaire:

Enregistrer un commentaire