matplotlib: Plot Feature Importance with feature names

后端 未结 3 1259
春和景丽
春和景丽 2021-02-04 11:18

In R there are pre-built functions to plot feature importance of Random Forest model. But in python such method seems to be missing. I search for a method in matplotlib

3条回答
  •  无人共我
    2021-02-04 11:54

    It's possible to just pass df.columns as the parameter for plt.xticks(),i have written a sample implementation.

    plt.bar( range(len(model.feature_importances_)), model.feature_importances_)
    plt.xticks(range(len(model.feature_importances_)), train_features.columns)
    plt.show()
    

提交回复
热议问题