python - Scikit-learn (sklearn) PCA throws Type Error on sparse matrix -


from documentation of sklearn randomizedpca, sparse matrices accepted input. when called sparse matrix, got typeerror :

> sklearn.__version__ '0.16.1' > pca = randomizedpca(n_components=2) > pca.fit(my_sparce_mat) typeerror: sparse matrix passed, dense data required. use x.toarray() convert dense numpy array. 

i obtained same error using fit_transform.

any suggestion on how have work?

the answer is not possible have randomizedpca work sparse matrix version 0.16.1 of scikit-learn (current stable version). documentation referring previous version of scikit-learn , alternative functions should used current stable version.

a possible alternative truncatedsvd


Comments

Popular posts from this blog

javascript - three.js lot of meshes optimization -

smartface.io - Proper way to change color scheme for whole application -

Email notification in google apps script -