Trees & Ensembles
Decision trees, random forests and gradient boosting — how each learns, why boosting fits residuals, and XGBoost and LightGBM as implementations rather than as answers.
A tree is a sequence of `feature < threshold?` questions ending in a constant. Readable, axis-aligned, piecewise flat — and incapable of predicting a value it has never seen.
Gini, entropy or variance reduction score each candidate cut; the greedy search picks the best one at each node and recurses. Stopping rules are the only thing between that and a leaf per point.
Many deep trees, each on a bootstrap sample and a random feature subset, averaged. Variance falls because the trees disagree; the out-of-bag rows give a free validation estimate; the artifact is large.
Fit a tree, compute the residuals, fit the next tree to them, repeat. Each tree follows the negative gradient of the loss; the learning rate shrinks each step; the number of trees is the capacity knob, chosen by early stopping.
Second-order gradients, a regularised objective, histogram binning, leaf-wise growth, native missing-value and categorical handling — what the fast implementations add to boosting, at the level of the mechanism and never the API.
A single tree, a forest, boosting and a linear model scored on quality, latency, cost, interpretability, data needed and operations — and the cases where boosting is the wrong answer even though it would win the benchmark.