Reputation: 2978
How can I know which particular features are selected with RFECV
? If I do X_rfecv_train=selector.transform(X_train)
, I get a numpy array, but I don't know feature names...
rf_rec = RandomForestClassifier(n_jobs=-1, max_depth = 20, max_features = 0.9,
min_samples_leaf = 2, min_samples_split = 0.1,
n_estimators = 100, oob_score=True, class_weight="balanced",
random_state=0)
selector = RFECV(rf_rec, step=1, cv=5)
selector = selector.fit(X_train, y_train)
X_rfecv_train=selector.transform(X_train)
X_rfecv_test=selector.transform(X_test)
Upvotes: 1
Views: 1526
Reputation: 36599
You can use the get_support()
. All selectors in scikit-learn should have this method.
print(selector.get_support(indices=True))
This will print the index of your original features which are selected and present in X_rfecv_train
and X_rfecv_test
.
Upvotes: 3