Sklearn PCA is pca.components_ the loadings?

拜拜、爱过 提交于 2019-12-21 04:25:21

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/36380183/sklearn-pca-is-pca-components-the-loadings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!