Part V — Non-Linear Models, Trees, Ensembles & Kernel Methods · Chapter 10

Build a high-performance tabular ML pipeline

Hook

This part built three genuinely different ways to fight overfitting: average many overfit trees, chain weak learners toward the gradient, and vote by similarity in a kernel space. Run all three on the exact same data — and on their own naive settings — who actually wins?

Intuition
Random Forest (20 bagged trees) — validation accuracy = 92%

This is the same 25-point noisy training set and 24-point clean validation set from the trees chapters, unchanged. Switch models and watch the fitted regions redraw completely, even though nothing about the data did.

Formalize

Every model here answers the same question — where's the boundary at x=9.5x=9.5? — but each one combines evidence its own way:

y^(x)=majority voteorsign(mhm(x))orsign(isign(yi)eγ(xxi)2)\hat{y}(x) = \text{majority vote} \quad \text{or} \quad \text{sign}\Big(\textstyle\sum_m h_m(x)\Big) \quad \text{or} \quad \text{sign}\Big(\textstyle\sum_i \text{sign}(y_i)\,e^{-\gamma(x-x_i)^2}\Big)
  • y^(x)\hat{y}(x) — the model's final predicted label at input xx.
  • hm(x)h_m(x) — round mm's stump prediction, for the boosted ensemble.
  • γ\gamma — the kernel's bandwidth: how quickly similarity falls off with distance.
  1. Random Forest

    Twenty bagged, individually-overfit depth-6 trees, majority-voted (Chapter 3).

  2. XGBoost-style booster

    A squared-loss, Newton-boosted stump ensemble — five rounds, split by the exact gain formula GL2/(HL+λ)+GR2/(HR+λ)G_L^2/(H_L+\lambda) + G_R^2/(H_R+\lambda) from Chapter 6 — run once with no regularization and once with λ=1\lambda=1.

  3. Kernel SVM (simplified)

    Every training point votes with an RBF-kernel-weighted sign, run once with a too-narrow bandwidth (γ=1\gamma=1) and once tuned (γ=0.1\gamma=0.1). A real SVM solves for a sparse set of support-vector weights; this keeps the essential mechanism — similarity-weighted, non-linear voting — at toy scale.

Play
Random Forest (20 bagged trees)
ModelTrainValidation
Random Forest (20 bagged trees)88%92%
XGBoost-style (5 rounds, λ=0)84%96%
XGBoost-style (5 rounds, λ=1)80%100%
Kernel SVM (γ=1, too narrow)100%79%
Kernel SVM (γ=0.1, tuned)80%100%

The too-narrow kernel SVM (γ=1\gamma=1) tops the training column at 100% — and comes in dead last on validation at 79%. It memorized the training set's five mislabeled points instead of the boundary between them. Random Forest can't out-train it (88%) but comfortably out-generalizes it (92%). Only the two regularized configurations — XGBoost with λ=1\lambda=1, and the kernel tuned to γ=0.1\gamma=0.1 — reach a perfect 100% validation, and both do it by explicitly damping how far a single point is allowed to move the decision.

Worked example
  1. XGBoost round 1 finds the exact boundary, with clean numbers

    Splitting at x=9.5x=9.5 (every point's toy Hessian is 1):

    • Left leaf: 10 points, GL=6G_L=6, HL=10H_L=10, so at λ=0\lambda=0: wL=6/10=0.6w_L^* = -6/10 = -0.6
    • Right leaf: 15 points, GR=9G_R=-9, HR=15H_R=15, so wR=9/15=0.6w_R^* = 9/15 = 0.6
    • Gain: 62/10+92/15=3.6+5.4=96^2/10 + 9^2/15 = 3.6 + 5.4 = 9, beating every other candidate threshold outright
  2. Regularization pulls both leaf values toward zero

    With λ=1\lambda=1 instead: wL=6/110.545w_L^* = -6/11 \approx -0.545 and wR=9/16=0.5625w_R^* = 9/16 = 0.5625 — both leaves take a smaller step. Small enough, across five rounds, that the ensemble never chases the noise into a wrong answer, landing at 100% validation instead of the unregularized version's 96%.

  3. A too-narrow kernel gets fooled by exactly one point

    At the clean validation point x=15.25x=15.25 (true label B), γ=1\gamma=1's kernel score comes out to 0.106\approx -0.106 — negative, predicting A — because the single nearby mislabeled training point at x=15x=15 dominates a kernel that's too narrow to look past its immediate neighbor.

  4. Widening the kernel fixes it, the same way weighting by shard size fixed averaging

    At γ=0.1\gamma=0.1, the same point's score is 3.05\approx 3.05 — solidly positive, predicting B correctly — because a wider kernel pools evidence from the many genuine B points surrounding that one noisy A, instead of trusting its nearest neighbor alone.

Checkpoint

Pick whichever model reaches the best validation accuracy on the scoreboard — 100%. More than one row can be right, and the highest training accuracy is a trap.

Kernel SVM (γ=1, too narrow) — validation accuracy = 79%
ModelTrainValidation
Random Forest (20 bagged trees)88%92%
XGBoost-style (5 rounds, λ=0)84%96%
XGBoost-style (5 rounds, λ=1)80%100%
Kernel SVM (γ=1, too narrow)100%79%
Kernel SVM (γ=0.1, tuned)80%100%
Pick a model to try it
Summary

The scoreboard's real lesson isn't which mechanism wins — every one of them is capable of reaching the true boundary, and every one of them is also capable of memorizing noise instead. Random Forest fights overfitting by averaging away disagreement, gradient boosting fights it by explicitly regularizing how far each round is allowed to step, and a kernel method fights it by choosing how wide a neighborhood counts as "similar." Three different knobs, one shared failure mode underneath, and the win was never "pick the fancier technique" — it was "use whichever knob this technique gives you correctly." This closes Part V. The next part turns to problems with no labels at all: clustering, dimensionality reduction, and time series.