Tree ensembles: XGBoost & LightGBM
Why gradient boosting still beats neural nets on most tabular problems, key knobs (learning rate, depth, early stopping), and handling class imbalance.
The mental model
Gradient boosting is a committee of specialists where each new member is hired to fix the previous committee's mistakes. The first tree makes a crude guess. You measure where it was wrong — the residuals — and train a second, small tree whose only job is to predict those errors. Add a shrunken slice of it to the running prediction, measure the new errors, train a third tree on those, and so on for hundreds of rounds. No single tree is good; the sum of many weak trees, each nudging the prediction toward the truth, is excellent.
Contrast this with a random forest, which is a committee where every member votes independently on the full problem and you average the votes. Forests reduce variance by averaging many decorrelated deep trees. Boosting reduces bias by sequentially correcting a shallow model — which is why boosted trees are typically shallow (depth 3–8) and numerous, while forest trees are deep and fewer.
The reason this still beats neural networks on most tabular data comes down to what trees are good at: axis-aligned splits handle mixed numeric/categorical features, missing values, monotonic-but-nonlinear relationships, and feature interactions without any scaling, embedding, or architecture search. A neural net has to *learn* the piecewise-constant structure that a tree gets for free. On a spreadsheet of 50 heterogeneous columns and 200k rows — the shape of most business problems — a well-tuned XGBoost or LightGBM model trains in seconds and wins. The WHY that matters for interviews: boosting's power is also its danger — because each tree chases the previous errors, an unregularized ensemble will happily memorize noise, so the entire craft is controlling that fitting with learning rate, depth, and early stopping.
- Deep dive
- Internal architecture
- Real-world use cases
- Best practices
- Common mistakes
- Performance
- Security
- Production troubleshooting
- Advantages & disadvantages
- Alternatives
- Interview expectations
- Interview questions
- Facts to remember
- Cheat sheet
- Quick revision