on-internet
← Community

Principal component analysis (PCA): Explained variance remains the same after changing dataframe position

Stack Overflow ·

I have a dataframe where A and B is used to predict C: df = df[['A', 'B', 'C']] array = df.values X = array[:, 0:-1] Y = array[:, -1] # Feature Importance model = GradientBoostingClassifier() model.fit(X, Y) print ("Importance:") print((model.feature_importances_)*100) # PCA pca = PCA(n_components=len(df.columns)-1) fit = pca.fit(X) print("Explained Variance") print(fit.explained_variance_ratio_) This prints Importance: [ 53.37975706 46.62024294] Explained Variance [ 0.98358394 0.01641606] However, when I changed the dataframe position swapping A and B, only the importance changed, but the Exp

Comments

Sign in or sign up to comment and upvote.

No comments yet.