Is it possible to combine the results from the xgb.boost importance function. For example, due to one hot encoding, I have a feature age=35 and another age=60. Is there a way that I can add these to get an overall importance of age, and not just age at every value? In case it matters the model is a binary:logistic one.

imp_matrix= xgb.importance(features,model=mod)

1 Answer 1


You can just sum them.

The three importances reported are all fractions that a given feature contributes out of the total. The measures are Gain, the impurity improvement a split provides; Cover, the number of datapoints passing through a node; and Frequency, just the number of nodes. All of these are summed across the nodes that use a given feature to split, and so adding them together across dummy variables for a given categorical also makes sense.


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.