Skip to content

Instantly share code, notes, and snippets.

@ayanatherate
Forked from MLWhiz/rfe.py
Created September 3, 2022 07:32
Show Gist options
  • Save ayanatherate/d294313a18092e238b1ecf1750004a38 to your computer and use it in GitHub Desktop.
Save ayanatherate/d294313a18092e238b1ecf1750004a38 to your computer and use it in GitHub Desktop.
from sklearn.feature_selection import RFE
from sklearn.linear_model import LogisticRegression
rfe_selector = RFE(estimator=LogisticRegression(), n_features_to_select=num_feats, step=10, verbose=5)
rfe_selector.fit(X_norm, y)
rfe_support = rfe_selector.get_support()
rfe_feature = X.loc[:,rfe_support].columns.tolist()
print(str(len(rfe_feature)), 'selected features')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment