【问题标题】:How to get feature importance in xgboost by 'information gain'?如何通过“信息增益”获得 xgboost 中的特征重要性?
【发布时间】:2017-04-07 20:13:08
【问题描述】:

我们可以通过“权重”获得特征重要性:

model.feature_importances_

但这不是我想要的。我想通过信息获取的重要性。

我们可以通过“增益”图获得特征重要性:

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

但是,我不知道如何从上图中获取特征重要性数据。或者

是否有像model.feature_importances_ 这样的功能来赋予增益功能重要性?这两种方法中的任何一种都可以。如果问题不清楚,请在 cmets 中告诉我

【问题讨论】:

    标签: python python-3.x matplotlib machine-learning xgboost


    【解决方案1】:

    在当前版本的 Xgboost 中,默认的重要性类型是 gain,参见 docs 中的 importance_type

    特征重要性也可以使用来自scikit-learn 包的permutation_importanceSHAP 值来计算。您可以在我的this blog post 中阅读有关在 Xgboost 中计算特征重要性的替代方法的详细信息。

    【讨论】:

      【解决方案2】:

      你可以从

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

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

      【讨论】:

      • model.get_booster().get_score(importance_type='gain') 为我工作....看起来它已更新
      【解决方案3】:

      其实我对你的问题有点不清楚,但我还是会试着回答一下。

      我猜你需要像特征选择这样的东西。如果我是对的,那么您可以检查 sklearn.feature_selection。

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

      有很多重要的函数,如chi2、SelectKBest、mutual_info_classif、f_regression、mutual_info_regression等。

      【讨论】:

      • 问题与特征选择无关。它只是关于我们从模型中获得的特征重要性。通常我们根据 f 分数或重量得到它。但我想要一个基于“信息增益”的树
      猜你喜欢
      • 2019-12-13
      • 2020-01-28
      • 2020-03-17
      • 1970-01-01
      • 2019-04-15
      • 1970-01-01
      • 2020-10-26
      • 2020-08-20
      • 2019-07-22
      相关资源
      最近更新 更多