Reputation: 1209
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? Either of the two ways will work. Please let me know in comments if the question is not clear
Upvotes: 5
Views: 12645
Reputation: 5839
In the current version of Xgboost the default type of importance is gain
, see importance_type
in the docs.
The feature importance can be also computed with permutation_importance
from scikit-learn
package or with SHAP
values. You can read details on alternative ways to compute feature importance in Xgboost in this blog post of mine.
Upvotes: 0
Reputation: 1209
You can get it from
model.booster().get_score(importance_type='gain')
http://xgboost.readthedocs.io/en/latest/python/python_api.html
Upvotes: 10
Reputation: 195
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.
Following is the URL: 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..
Upvotes: 0