When you train your XGBoost regression model, you can obtain feature importances by using:


Although I tried to reconstruct the value and have done some research on it, I am still struggling to figure out, how gain is computed in XGBoost?

It is partially explained here: Relative variable importance for Boosting

But this is focused on classification. And even though there is a link saying that squared error with Friedman's improvement score is used, I have not reached the same numbers.

  • $\begingroup$ I need to edit that answer of mine. In fact, regression trees are always used in boosting. So it is subtly incorrect. $\endgroup$ Commented Sep 7, 2017 at 14:42

1 Answer 1


After all it seems that gain is computed in quite complicated manner and it's explanation can be found at https://xgboost.readthedocs.io/en/latest/tutorials/model.html at the bottom of the page.

Gain is a metric defined by XGBoost and it also involves evaluation of the structure of the tree.

Due to the complexity of the explanation, it is not copied in here.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.