Is it possible to extract eigenvalues from PCA estimator from sklearn?

2.2k Views Asked by At

After I fit some data with PCA:

estimator = PCA(n_components)
estimator.fit(mydat)

can I obtain eigenvalues of covariance matrix, which were computed inside (and which IMO are equal to variances of projected data)?

1

There are 1 best solutions below

0
On

The eigenvalues should be in:

estimator.explained_variance_

If you compare it with another software, do not forget to standardize the data first:

import sklearn.preprocessing
mydat = sklearn.preprocessing.StandardScaler().fit_transform(mydat_before_std)

Then you should have results close to what R would give you.