I am fitting xgboost model (scala-spark) to my dataset of transactions. I have about 2 millions of transactions in my training set which is highly unbalanced with a ratio of positive/negative<0.001 classes. I have now about 300 features in the model.

Then I take an output model and count for each feature

  • In how many trees a feature was present
  • In how many splits a feature was present

Then I sort the features from the ones with most trees to least trees. I get some results that I am not sure of. Features at the top of the list with most trees and splits basically appear in each single xgboost tree multiple times. For example in xgboost with 100 rounds and colsample_bytree=1.0 and max_depth=6 I would see a feature A appear in 100 trees and in ~400 splits. Feature B appears in 98 trees and 350 splits etc... Basically it seems that all my trees are based on all the same same top features in different configurations.


Does it mean:

  • It normal
  • Do those features overfit my model
  • I tried to force model to take other features by decreasing colsample_bytree or colsample_bylevel and it helps but somewhat, but model performance does not dramattically improve.

Any other suggestions?

Update Observations (Feb 2019)

  • The features are continuous not categorical
  • When I sort all features based on their total gain (sum of gain in all nodes that split on the feature), the features that appear in all trees multiple times can have highest total gain or quite low total gain. There is not rule here.
  • $\begingroup$ For question 1, if a feature is really very important, it is quite likely to be used to split multiple times in a tree. I am a little surprised that it would keep getting used in each of the 100 subsequent trees; I would expect at some point the residuals would have all the information from that feature extracted out. Are these features continuous, or categorical? How many levels? $\endgroup$
    – Ben Reiniger
    Commented Feb 1, 2019 at 18:20
  • $\begingroup$ @BenReiniger Hi, I added some extra info to my post to answer your question. $\endgroup$
    – astro_asz
    Commented Feb 4, 2019 at 9:42

1 Answer 1


To your questions:

  1. It can be normal.
  2. Features itself are not responsible for overfitting. It can be noise from them or just correlation without causation. I.e. Feature correlates in the training set, but not in the test set. Overfitting is related to models.
  3. Maybe you still don't have a feature that would improve your model significantly. It's hard to say with such limited information. You need to try some experiments with feature selection.

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.