XGBoost vs LightGBM · 6 Real-World Benchmarks

12 min read

XGBoost and LightGBM are the two dominant gradient boosting libraries. Both implement boosted trees with similar mathematical foundations, but diverge in tree-growing strategy, categorical feature handling, and computational optimizations.

Core Difference: Level-wise vs Leaf-wise Growth

XGBoost grows trees level-wise (breadth-first). LightGBM grows leaf-wise (best-first), picking the leaf with highest split gain at each step.

Leaf-wise growth produces deeper, asymmetric trees that can capture more complex patterns with fewer total leaves — often yielding higher accuracy. Level-wise growth produces balanced trees that are inherently more regularized — less prone to overfitting on small datasets.

Benchmark Results

Large-scale (Higgs, 11M samples)

LightGBM trains ~3× faster (150s vs 420s) with ~50% less memory (1.2 GB vs 2.8 GB) and marginally better AUC (0.845 vs 0.839).

Categorical-heavy data

LightGBM’s native categorical_feature parameter provides a decisive advantage. XGBoost requires one-hot encoding, expanding the feature space.

Small datasets (<50K samples)

Differences narrow significantly. XGBoost with tree_method='hist' performs within 10% of LightGBM’s speed with often better-calibrated probabilities.

Imbalanced classification

LightGBM tends to produce higher recall at fixed precision — leaf-wise growth dedicates deep branches to the minority class. XGBoost’s scale_pos_weight implementation is more mature and predictable for production.

GPU training

XGBoost holds a slight edge (~20%) on NVIDIA A100, but both are fast enough that GPU training time is rarely the bottleneck.

Inference speed

XGBoost wins decisively for latency-sensitive applications. Level-wise trees bound the worst-case inference path; LightGBM’s asymmetric trees can have longer paths.

When to Choose

ScenarioRecommendation
Default startXGBoost (mature ecosystem, better docs)
100M+ rowsLightGBM (faster training, less memory)
Many categorical featuresLightGBM (native support)
Production inferenceXGBoost (bounded inference time)
Kaggle competitionLightGBM (higher accuracy ceiling)
InterpretabilityXGBoost (first-class SHAP integration)

For most practical problems, the choice matters less than proper feature engineering, cross-validation, and hyperparameter tuning. Both are state-of-the-art. Pick one, learn it well.