How to print the feature importance list in CPP API

https://github.com/dmlc/xgboost/blob/master/include/xgboost/c_api.h

THX!!!

XGBoosterPredict has a param which says “4:output feature contributions to individual predictions”

But I don’t know how to use it.

By “feature importance,” do you want something equivalent to http://xgboost.readthedocs.io/en/latest/python/python_api.html#xgboost.Booster.get_fscore ?

Yes!THX!in CPP API, how to …

There is no feature equivalent to get_fscore in C API. You’ll have to dump the model with XGBoosterDumpModel() and manually parse Gain and Cover to compute feature importance. See


for the logic of computing feature importance.