XGBoost and Gradient Boosting
The one idea: A random forest builds many trees independently and averages their votes — a panel of experts working in parallel, none aware of the others' mistakes. Gradient boosting builds trees one at a time, and each new tree's entire job is to correct the errors the ensemble-so-far is still making. That sequential, error-correcting structure is why boosted models (XGBoost chief among them) dominate tabular-data leaderboards — and why they overfit fast if you let the sequence run too long.
⚠️ The trap: More boosting rounds can only help, since each new tree is fixing mistakes — so crank n_estimators up and let it run. That feels right and it's backwards. Past a certain point, each new tree stops correcting genuine signal and starts correcting the previous trees' noise-chasing — training error keeps falling while validation error turns around and climbs; more rounds without a stopping rule reliably makes a boosted model worse, not better.
Random forests and gradient-boosted trees are both "ensembles of decision trees," and it's tempting to treat them as two flavors of the same thing. They're not. The difference in how the trees are built — independently versus sequentially — is the whole story, and it explains both why boosting tends to win competitions and why it's more dangerous to leave on autopilot.
Two ways to combine trees: parallel experts vs. a relay of specialists
A random forest is a committee of independent experts. Each tree is grown on its own bootstrap sample (a random resample of the training rows, with replacement) and its own random subset of features at each split. Critically, none of the trees…
Keep reading: Xgboost
Unlock the full Machine Learning track — every lesson, the AI tutor, and full mock assessments.
- Full lesson content
- AI tutor for this section
- Practice questions