PCA on sklearn - how to interpret pca.components_

后端 未结 2 971
伪装坚强ぢ
伪装坚强ぢ 2021-01-30 14:58

I ran PCA on a data frame with 10 features using this simple code:

pca = PCA()
fit = pca.fit(dfPca)

The result of pca.explained_variance_

2条回答
  •  灰色年华
    2021-01-30 15:22

    Basic Idea

    The Principle Component breakdown by features that you have there basically tells you the "direction" each principle component points to in terms of the direction of the features.

    In each principle component, features that have a greater absolute weight "pull" the principle component more to that feature's direction.

    For example, we can say that in PC1, since Feature A, Feature B, Feature I, and Feature J have relatively low weights (in absolute value), PC1 is not as much pointing in the direction of these features in the feature space. PC1 will be pointing most to the direction of Feature E relative to other directions.

    Visualization in Lower Dimensions

    For a visualization of this, look at the following figures taken from here and here:

    The following shows an example of running PCA on correlated data.

    We can visually see that both eigenvectors derived from PCA are being "pulled" in both the Feature 1 and Feature 2 directions. Thus, if we were to make a principle component breakdown table like you made, we would expect to see some weightage from both Feature 1 and Feature 2 explaining PC1 and PC2.

    Next, we have an example with uncorrelated data.

    Let us call the green principle component as PC1 and the pink one as PC2. It's clear that PC1 is not pulled in the direction of feature x', and as isn't PC2 in the direction of feature y'. Thus, in our table, we must have a weightage of 0 for feature x' in PC1 and a weightage of 0 for feature y' in PC2.

    I hope this gives an idea of what you're seeing in your table.

提交回复
热议问题