python feature selection in pipeline: how determine feature names?

后端 未结 3 1833
眼角桃花
眼角桃花 2021-02-03 12:11

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

3条回答
  •  感动是毒
    2021-02-03 13:14

    Jake's answer totally works. But depending on what feature selector your using, there's another option that I think is cleaner. This one worked for me:

    X.columns[features.get_support()]
    

    It gave me an identical answer to Jake's answer. And you can see more about it in the docs, but get_support returns an array of true/false values for whether or not the column was used. Also, it's worth noting that X must be of identical shape to the training data used on the feature selector.

提交回复
热议问题