# What are the differences between the below feature selection methods?

Do the below codes do the same? If not, what are the differences?

fs = RFE(estimator=RandomForestClassifier(), n_features_to_select=10)
fs.fit(X, y)
print(fs.support_)

fs = SelectFromModel(RandomForestClassifier(), max_features=10)
fs.fit(X, y)
print(fs.support_)

fs= RandomForestClassifier(),
fs.fit(X, y)
print(fs.feature_importances_[:10,])


As the name suggests, "recursive feature elimination" (RFE) recursively eliminates features, by fitting the model and throwing away the least-important one(s). After removing one feature, the next iteration may find the remaining features have changed order of importance. This is especially true in the presence of correlated features: they may split importance when included together, so might both be dropped by your second approach; but in RFE, one gets dropped at some point, but then the other one appears more important in the following iterations (since it no longer splits its importance with its now-dropped companion) and so is kept.
• Thanks for your answer, but what about using SelectFromModel(RandomForestClassifier(), max_features=10) it is equal to any of them? Jun 4 at 21:53
• (I've edited the question and answer to add the SelectFromModel approach.) Jun 5 at 15:42