简体   繁体   English

如何通过“信息增益”获得 xgboost 中的特征重要性?

[英]How to get feature importance in xgboost by 'information gain'?

we can get feature importance by 'weight' :我们可以通过“权重”获得特征重要性:

model.feature_importances_

But this is not what i want.但这不是我想要的。 I want by importances by information gain.我想要通过信息获取的重要性。

we can get feature importance by 'gain' plot :我们可以通过“增益”图获得特征重要性:

xgboost.plot_importance(model, importance_type='gain')

However, I don't know how to get feature importance data from above plot.但是,我不知道如何从上面的图中获取特征重要性数据。 Or或者

if there is function like model.feature_importances_ to give gain feature importance?如果有像model.feature_importances_这样的model.feature_importances_来获得特征重要性? Either of the two ways will work.这两种方式中的任何一种都可以。 Please let me know in comments if the question is not clear如果问题不清楚,请在评论中告诉我

You can get it from你可以从

model.booster().get_score(importance_type='gain')

http://xgboost.readthedocs.io/en/latest/python/python_api.html http://xgboost.readthedocs.io/en/latest/python/python_api.html

Actually, I am a bit unclear about your question but still I'll try to answer this.实际上,我对您的问题有点不清楚,但我仍然会尝试回答这个问题。

I guess you need something like feature selection.我想你需要像特征选择这样的东西。 If I am right, then you can check sklearn.feature_selection.如果我是对的,那么您可以检查 sklearn.feature_selection。

Following is the URL: http://scikit-learn.org/stable/modules/feature_selection.html以下是网址: http : //scikit-learn.org/stable/modules/feature_selection.html

There are many important functions like chi2, SelectKBest, mutual_info_classif, f_regression, mutual_info_regression, etc..有很多重要的函数,如 chi2、SelectKBest、mutual_info_classif、f_regression、mutual_info_regression 等。

In the current version of Xgboost the default type of importance is gain , see importance_type in the docs .在当前版本的 Xgboost 中,重要性的默认类型是gain ,请参阅文档中的importance_type

The feature importance can be also computed with permutation_importance from scikit-learn package or with SHAP values.也可以使用scikit-learn包中的permutation_importanceSHAP值来计算特征重要性。 You can read details on alternative ways to compute feature importance in Xgboost in this blog post of mine.您可以在我的这篇博文中阅读有关在 Xgboost 中计算特征重要性的替代方法的详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM