Complete the code to import the Recursive Feature Elimination class from scikit-learn.
from sklearn.feature_selection import [1]
The Recursive Feature Elimination class is called RFE in scikit-learn.
Complete the code to create an RFE object using a logistic regression model as the estimator.
from sklearn.linear_model import LogisticRegression rfe = RFE(estimator=[1], n_features_to_select=3)
RFE requires an estimator to rank features. Here, LogisticRegression() is used as the estimator.
Fix the error in the code to fit the RFE selector to data X and target y.
rfe = RFE(estimator=LogisticRegression(), n_features_to_select=2) rfe.[1](X, y)
To train the RFE selector on data, use the fit method.
Fill both blanks to select features and transform the dataset using the fitted RFE selector.
X_selected = rfe.[1](X) selected_features = rfe.[2]_
Use transform to reduce X to selected features, and support_ to get a mask of selected features.
Fill all three blanks to create an RFE selector, fit it, and print the ranking of features.
selector = RFE(estimator=[1], n_features_to_select=4) selector.[2](X, y) print(selector.[3]_)
Create the selector with LogisticRegression(), fit it with fit(), and get feature rankings with ranking_ attribute.