Skip to content

Instantly share code, notes, and snippets.

@Ayushijain09
Last active July 15, 2020 12:08
Show Gist options
  • Save Ayushijain09/a4bce2c23bf0bb12f85cdc7b741a7d5f to your computer and use it in GitHub Desktop.
Save Ayushijain09/a4bce2c23bf0bb12f85cdc7b741a7d5f to your computer and use it in GitHub Desktop.
Anova feature selection
from sklearn.feature_selection import SelectKBest
from sklearn.feature_selection import f_regression
fvalue_selector = SelectKBest(f_regression, k=20) #select features with 20 best ANOVA F-Values
X_train_new = fvalue_selector.fit_transform(X_train, y_train)
print(X_train.shape, X_train_new.shape) #output (143, 59) (143, 20)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment