is there away to output selected columns names from SelectFromModel method?

前端 未结 2 1125
庸人自扰
庸人自扰 2021-01-02 13:39

i performed feature selection using ExtraTreesClassifier and SelectFromModel in data set that loaded as DataFrame, however i want to save these selected feature as DataFrame

相关标签:
2条回答
  • 2021-01-02 14:25
    model = SelectFromModel(clf, prefit=True)
    feature_idx = model.get_support()
    feature_name = df.columns[feature_idx]
    
    0 讨论(0)
  • 2021-01-02 14:41

    Use the method DataFrame.to_csv() to save your dataframe as a csv file.

    Do the following :

    X_new.to_csv("your/path", sep=';')
    

    Here is a link to the documentation of the method.

    0 讨论(0)
提交回复
热议问题