How To Do Forward Feature Selection In Python

[Solved] How To Do Forward Feature Selection In Python | Shell - Code Explorer | yomemimo.com
Question : how to do forward feature selection in python

Answered by : aman-kumar-verma

#importing the necessary libraries
from mlxtend.feature_selection import SequentialFeatureSelector as SFS
from sklearn.linear_model import LinearRegression
# Sequential Forward Selection(sfs)
sfs = SFS(LinearRegression(), k_features=11, forward=True, floating=False, scoring = 'r2', cv = 0)
sfs.fit(X, y)
sfs.k_feature_names_ # to get the final set of features

Source : https://www.analyticsvidhya.com/blog/2020/10/a-comprehensive-guide-to-feature-selection-using-wrapper-methods-in-python/ | Last Update : Thu, 12 Aug 21

Answers related to how to do forward feature selection in python

Code Explorer Popular Question For Shell