How to get feature importance in xgboost?

后端 未结 11 1779
情深已故
情深已故 2020-12-13 07:00

I\'m using xgboost to build a model, and try to find the importance of each feature using get_fscore(), but it returns {}

and my train code

11条回答
  •  感动是毒
    2020-12-13 07:40

    For feature importance Try this:

    Classification:

    pd.DataFrame(bst.get_fscore().items(), columns=['feature','importance']).sort_values('importance', ascending=False)
    

    Regression:

    xgb.plot_importance(bst)
    

提交回复
热议问题