简体   繁体   中英

Sklearn PCA is pca.components_ the loadings?

Sklearn PCA is pca.components_ the loadings? I am pretty sure it is, but I am trying to follow along a research paper and I am getting different results from their loadings. I can't find it within the sklearn documentation.

pca.components_ is the orthogonal basis of the space your projecting the data into. It has shape (n_components, n_features) . If you want to keep the only the first 3 components (for instance to do a 3D scatter plot) of a datasets with 100 samples and 50 dimensions (also named features), pca.components_ will have shape (3, 50) .

I think what you call the "loadings" is the result of the projection for each sample into the vector space spanned by the components. Those can be obtained by calling pca.transform(X_train) after calling pca.fit(X_train) . The result will have shape (n_samples, n_components) , that is (100, 3) for our previous example.

This previous answer is mostly correct except about the loadings. components_ is in fact the loadings, as the question asker originally stated. The result of the fit_transform function will give you the principal components (the transformed/reduced matrix).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM