[英]How to get feature importance in xgboost by 'information gain'?
我们可以通过“权重”获得特征重要性:
model.feature_importances_
但这不是我想要的。 我想要通过信息获取的重要性。
我们可以通过“增益”图获得特征重要性:
xgboost.plot_importance(model, importance_type='gain')
但是,我不知道如何从上面的图中获取特征重要性数据。 或者
如果有像model.feature_importances_
这样的model.feature_importances_
来获得特征重要性? 这两种方式中的任何一种都可以。 如果问题不清楚,请在评论中告诉我
你可以从
model.booster().get_score(importance_type='gain')
http://xgboost.readthedocs.io/en/latest/python/python_api.html
实际上,我对您的问题有点不清楚,但我仍然会尝试回答这个问题。
我想你需要像特征选择这样的东西。 如果我是对的,那么您可以检查 sklearn.feature_selection。
以下是网址: http : //scikit-learn.org/stable/modules/feature_selection.html
有很多重要的函数,如 chi2、SelectKBest、mutual_info_classif、f_regression、mutual_info_regression 等。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.