i used pipeline and grid_search to select the best parameters and then used these parameters to fit the best pipeline (\'best_pipe\'). However since the feature_selection (Selec
This could be an instructive alternative: I encountered a similar need as what was asked by OP. If one wants to get the k best features' indices directly from GridSearchCV
:
finalFeatureIndices = gs.best_estimator_.named_steps["feat"].get_support(indices=True)
And via index manipulation, can get your finalFeatureList
:
finalFeatureList = [initialFeatureList[i] for i in finalFeatureIndices]