Skip to content

Instantly share code, notes, and snippets.

@MLWhiz
Created July 27, 2019 16:56
Show Gist options
  • Save MLWhiz/9805155da5f190cd4585844803b09f57 to your computer and use it in GitHub Desktop.
Save MLWhiz/9805155da5f190cd4585844803b09f57 to your computer and use it in GitHub Desktop.
from sklearn.feature_selection import SelectKBest
from sklearn.feature_selection import chi2
from sklearn.preprocessing import MinMaxScaler
X_norm = MinMaxScaler().fit_transform(X)
chi_selector = SelectKBest(chi2, k=num_feats)
chi_selector.fit(X_norm, y)
chi_support = chi_selector.get_support()
chi_feature = X.loc[:,chi_support].columns.tolist()
print(str(len(chi_feature)), 'selected features')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment