python feature selection in pipeline: how determine feature names?

后端 未结 3 1762
眼角桃花
眼角桃花 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 12:54

    You can access the feature selector by name in best_pipe:

    features = best_pipe.named_steps['feat']
    

    Then you can call transform() on an index array to get the names of the selected columns:

    X.columns[features.transform(np.arange(len(X.columns)))]
    

    The output here will be the eighty column names selected in the pipeline.

提交回复
热议问题