如何通过 'information gain' 获得 xgboost 中的特征重要性?
How to get feature importance in xgboost by 'information gain'?
我们可以通过 'weight' 获得特征重要性:
model.feature_importances_
但这不是我想要的。我想通过信息获取的重要性。
我们可以通过 'gain' plot 得到特征重要性:
xgboost.plot_importance(model, importance_type='gain')
但是,我不知道如何从上面的图中获取特征重要性数据。或者
是否有像model.feature_importances_
这样的功能来赋予增益特征重要性?这两种方法中的任何一种都可以。如果问题不清楚,请在评论中告诉我
其实我对你的问题有点不清楚,不过我还是会尽量回答的。
我猜你需要像特征选择这样的东西。如果我是对的,那么你可以查看 sklearn.feature_selection.
以下是URL:
http://scikit-learn.org/stable/modules/feature_selection.html
有许多重要函数,如 chi2、SelectKBest、mutual_info_classif、f_regression、mutual_info_regression 等。
您可以从
获取
model.booster().get_score(importance_type='gain')
http://xgboost.readthedocs.io/en/latest/python/python_api.html
在当前版本的 Xgboost 中,默认的重要性类型是 gain
,参见 docs 中的 importance_type
。
特征重要性也可以使用 scikit-learn
包中的 permutation_importance
或 SHAP
值来计算。您可以在我的 this blog post 中阅读有关在 Xgboost 中计算特征重要性的替代方法的详细信息。
我们可以通过 'weight' 获得特征重要性:
model.feature_importances_
但这不是我想要的。我想通过信息获取的重要性。
我们可以通过 'gain' plot 得到特征重要性:
xgboost.plot_importance(model, importance_type='gain')
但是,我不知道如何从上面的图中获取特征重要性数据。或者
是否有像model.feature_importances_
这样的功能来赋予增益特征重要性?这两种方法中的任何一种都可以。如果问题不清楚,请在评论中告诉我
其实我对你的问题有点不清楚,不过我还是会尽量回答的。
我猜你需要像特征选择这样的东西。如果我是对的,那么你可以查看 sklearn.feature_selection.
以下是URL: http://scikit-learn.org/stable/modules/feature_selection.html
有许多重要函数,如 chi2、SelectKBest、mutual_info_classif、f_regression、mutual_info_regression 等。
您可以从
获取model.booster().get_score(importance_type='gain')
http://xgboost.readthedocs.io/en/latest/python/python_api.html
在当前版本的 Xgboost 中,默认的重要性类型是 gain
,参见 docs 中的 importance_type
。
特征重要性也可以使用 scikit-learn
包中的 permutation_importance
或 SHAP
值来计算。您可以在我的 this blog post 中阅读有关在 Xgboost 中计算特征重要性的替代方法的详细信息。