coming back to scikit-learnwe find various excellent wrapper classes in the sklearn feature_selection package real workhorse in this field is rfewhich stands for recursive feature elimination it takes an estimator and the desired number of features to keep as parameters and then trains the estimator with various feature sets as long as it has found subset of the features that are small enough the rfe instance itself pretends to be like an estimatortherebywrapping the provided estimator in the following examplewe create an artificial classification problem of samples using the convenient make_classification(function of datasets it lets us specify the creation of featuresout of which only three are really valuable to solve the classification problemfrom sklearn feature_selection import rfe from sklearn linear_model import logisticregression from sklearn datasets import make_classification , make_classification(n_samples= n_features= n_ informative= random_state= clf logisticregression(clf fit(xyselector rfe(clfn_features_to_select= selector selector fit(xyprint(selector support_[false true false true false false false false true falseprint(selector ranking_[ the problem in real-world scenarios isof coursehow can we know the right value for n_features_to_selecttruth iswe can' but most of the timewe can use sample of the data and play with it using different settings to quickly get feeling for the right ballpark the good thing is that we don' have to be that exact when using wrappers let' try different values for n_features_to_select to see how support_ and ranking_ changen_ features_ to_select support_ ranking_ [false false false true false false false false false false [false false false true false false false false true false[ [false true false true false false false false true false[