Compute factoring loadings and eigenvalues using sklearn's PCA (principal component analysis) model


From here:

By default, sklearn's PCA model doesn't directly give factoring loadings or eigenvalues. Computing those is pretty easy, though. For example:

from sklearn.decomposition import PCA

x = get_data_somehow()
pca = PCA()
pca.fit(x)

loadings = pca.components_.T
eigenvalues = pca.singular_values_ ** 2