recursive feature elimination as the name suggestsrfe (recursive feature eliminationfeature selection technique removes the attributes recursively and builds the model with remaining attributes we can implement rfe feature selection technique with the help of rfe class of scikit-learn python library example in this examplewe will use rfe with logistic regression algorithm to select the best attributes having the best features from pima indians diabetes dataset to from pandas import read_csv from sklearn feature_selection import rfe from sklearn linear_model import logisticregression path ' :\pima-indians-diabetes csvnames ['preg''plas''pres''skin''test''mass''pedi''age''class'dataframe read_csv(pathnames=namesarray dataframe values nextwe will separate the array into its input and output componentsx array[:, : array[:, the following lines of code will select the best features from datasetmodel logisticregression(rfe rfe(model fit rfe fit(xyprint("number of features% "print("selected features% "print("feature ranking% "output number of features selected featurestrue false false false false true true falsefeature ranking[ we can see in above outputrfe choose pregmass and pedi as the first best features they are marked as in the output