Paper commentary
A Comparative Analysis of XGBoost
Tuned XGBoost is not always the best choice over gradient boosting and random forest
- Problem Earlier large comparisons of ensemble methods left out gradient boosting algorithms. Nobody had tested whether XGBoost's gains over its gradient boosting base hold up.
- Method The authors compare XGBoost with gradient boosting and random forest on 28 UCI datasets. They use both tuned and default settings, with grid search picking each method's parameters.
- Results Tuned gradient boosting gave the highest accuracy on 10 of 28 datasets, compared to 8 for tuned XGBoost. The rank differences were not statistically significant.
Why gradient boosting needed a fresh comparison
Ensemble methods are now central to many applied systems, from credit scoring to energy forecasting. Random forest is often praised as one of the most accurate and fast methods, whatever the dataset. XGBoost, a scalable ensemble built on gradient boosting, has placed among the top contenders in Kaggle competitions. Yet none of the earlier large comparisons included an algorithm from the gradient boosting family.
That gap matters because XGBoost is a scalable variant of the gradient boosting it extends, so its gains over that base method are untested. The authors therefore compare XGBoost with gradient boosting, in accuracy and training speed, and use random forest as a benchmark. Random forest serves as the benchmark because earlier studies had already shown its strong performance.
How the three ensembles build their trees
Random forest averages many trees grown on different random samples, while gradient boosting adds trees one after another, each correcting the errors left by the ones before. Each random forest tree is trained on a bootstrap sample, drawn with replacement and the same size as the training set. Such a sample is expected to contain about 37% duplicated instances, so the trees see different data.
At each split only a random subset of the input variables is searched, and classification uses majority voting. Because the generalization error converges as trees are added, the number of trees isn't a parameter that needs tuning.
Gradient boosting treats each new model as a greedy gradient descent step, so it is fitted to the pseudo-residuals of the loss. The ensemble grows as an additive sum, \(F_m(x) = F_{m-1}(x) + \nu \rho_m h_m(x)\), where each new model is scaled by the shrinkage factor \(\nu\). Because the process can overfit, boosting relies on regularization such as shrinkage, limits on tree complexity and random subsampling without replacement.
XGBoost keeps this additive scheme but adds a penalty to the objective that depends on each tree's complexity. The penalty grows with the number of leaves T, weighted by γ, and with the squared norm of the leaf output scores w. Because the penalty enters the split criterion, it works as a pre-pruning strategy, and a higher γ gives simpler trees.
For speed, XGBoost stores each attribute pre-sorted in a column-based structure, so each attribute is sorted only once. It also tests candidate split points taken from data percentiles, and it handles missing values with a sparsity-aware search.
Data, grids and fair defaults
The comparison covers 28 classification datasets from the UCI repository, which differ in size, attributes, classes and missing values. Each dataset is evaluated with stratified 10-fold cross-validation. Within each training partition, a grid search with 10-fold cross-validation picks each method's parameters, and the best set then trains an ensemble on the whole training partition.
XGBoost was also trained for every combination in its grid, so alternative grids could be tested afterwards. Models with the default package parameters form a second set for comparison.
Every ensemble has 200 decision trees, and the authors don't treat ensemble size as a parameter to tune. The grid sizes differ, with 3840 combinations for XGBoost, 256 for random forest and 1920 for gradient boosting. Missing values are filled with the attribute mean through a scikit-learn class, which keeps the comparison fair across the three methods.
Accuracy: tuning changes the picture
Counting the datasets where each model is most accurate, tuned gradient boosting leads with 10 of 28 datasets. Tuned XGBoost comes next with 8 datasets, followed by default gradient boosting with 5. These counts are close, so they point to no clear overall winner.
The authors observe that default and tuned settings differ far more for XGBoost and gradient boosting than for random forest. Default XGBoost and default gradient boosting generally trail their tuned versions, but German, Parkinson and Vehicle are exceptions where default XGBoost beats tuned XGBoost. On German, default XGBoost scored 79.00%±4.22, compared to 77.40%±4.13 for tuned XGBoost.
The authors summarize the tables with average ranks, tested with a Nemenyi test at CD = 1.42. No pair among the six methods differs significantly, and tuned XGBoost has the best average rank, followed by default gradient boosting and default random forest. So the rank view places tuned XGBoost at the front of a close group rather than showing it to be the clear winner.
Training time and the cost of the grid search
For tuned models, the grid search accounts for over 99.9% of end-to-end training time for gradient boosting and XGBoost. Because the grid sizes differ, the search time can't be compared directly across classifiers. Measured on a single ensemble with fixed parameters, XGBoost is about 3.5 times faster than random forest and 2.4-4.3 times faster than gradient boosting.
All reported times are sequential, measured on an eight-core Intel i7-4790K, even though the grid search ran in parallel. Random forest and XGBoost use internal multi-threading and gradient boosting doesn't, but the authors argue this doesn't change the end-to-end grid-search cost, because the search is fully parallelizable. XGBoost's search still took less than half the time of gradient boosting's search, although its grid was twice as large.
The speed advantage isn't uniform, because on multiclass problems such as Segment and Soybean, XGBoost and gradient boosting slow down relative to random forest.
Which XGBoost parameter values work best on average
To judge parameter values, the authors averaged test-error ranks over all datasets across the 3840 XGBoost configurations. For each value they measured how often the average rank improves when that value is switched to another one, with all else fixed.
For gamma, the default 0 is far from the best choice, and values in [0.2, 0.3] look reasonable. Deeper trees score better on average, which the authors reconcile with shallow gradient boosting trees, because the depth is only a maximum and gamma also limits tree size. Feature sampling at 0.25, sqrt and log2 performs similarly, and the best subsampling value is 0.75.
Combining these results, the authors propose the defaults learning rate 0.05, gamma 0.2, depth 100 (unlimited), sqrt features and subsampling 0.75. This fixed setting beats the package default on 17 of 28 datasets, with large gains on Echo, Sonar and Tic-tac-toe. On Echo, accuracy rises from 94.46%±6.80 with the package default to 98.75%±3.75 with the proposed setting.
When the package default wins, the gap is usually small, except on German, Parkinson and Vehicle.
Dropping randomization from the search
The authors ask whether the gamma parameter gives any advantage, and whether the randomization parameters need to be searched. Random forest had already shown that tuning its randomization parameters isn't productive, which motivates the same test for XGBoost.
Two grids were run: one with gamma fixed at 0, and one with subsampling fixed at 0.75 and features at sqrt, while learning rate, gamma and depth were tuned. The grid without randomization tuning has the most best results, 11, compared to 9 for the full grid and 8 for the grid without gamma. On average ranks, the grid without randomization tuning comes first, then the full grid, then the grid without gamma, but these differences are not statistically significant.
So the small edge that gamma gives is a tendency, not a settled result.
The grid without randomization tuning is over 16 times faster than the full grid on average. The authors conclude that some randomization must stay on, and that fixing subsampling at 0.75 and features at sqrt is enough.
Limitations
The results cover 28 UCI classification datasets, and only ensembles of 200 trees were tested. Missing values were mean-imputed rather than handled by XGBoost's own mechanism, a choice made for fairness with the other two methods. Most accuracy differences are not statistically significant, so the rank results support only a tendency.
Parameter estimation inside the training folds may overfit noisy datasets, which the authors offer as one reason default XGBoost sometimes beats tuned XGBoost. The authors say their results aren't necessarily at odds with XGBoost's Kaggle results, but no competition data is analyzed. Timing was measured on one CPU, so the speed ratios may differ on other hardware.
Paper info
- Authors
- Candice Bentéjac, Anna Csörgő, Gonzalo Martínez-Muñoz
- Venue
- arXiv · Preprint
- First published
- 2019-11-5
- Added
- 2026-11-12
- Updated
- 2019-11-5
- Version
- v1
- arXiv
- 1911.01914
- DOI
- 10.1007/s10462-020-09896-5
- Category
- cs.LG · stat.ML
- Original paper terms
- arXiv non-exclusive 1.0
- What we show
- Paper info and commentary
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Quote from the paper
Candice Bentéjac, Anna Csörgő, Gonzalo Martínez-Muñoz (2019). A Comparative Analysis of XGBoost. arXiv:1911.01914v1. https://doi.org/10.1007/s10462-020-09896-5
BibTeX
@article{bentjac2019comparative,
title = {{A Comparative Analysis of XGBoost}},
author = {Candice Bentéjac and Anna Csörgő and Gonzalo Martínez-Muñoz},
year = {2019},
eprint = {1911.01914},
archivePrefix = {arXiv},
doi = {10.1007/s10462-020-09896-5},
url = {https://arxiv.org/abs/1911.01914v1}
}