Gradient Boosting visualized — sequential learning + residuals (breast cancer)
SEE how each tree corrects the PREVIOUS tree's errors. SEE how learning rate + n_estimators interact. The competition-winning algorithm.
The output will appear here.
Gradient Boosting — VISUALIZED: THE KEY DIFFERENCE from RandomForest: RF builds trees INDEPENDENTLY (bagging) → reduces VARIANCE. GB builds trees SEQUENTIALLY (boosting) → reduces BIAS. ALGORITHM: (1) Start with mean prediction: F₀(x) = mean(y). (2) Compute RESIDUALS: r = y - F₀(x). (How wrong is the current model?) (3) Train a tree to predict the RESIDUALS (not y). (4) Update: F₁ = F₀ + lr × tree₁. (Add the correction.) (5) New residuals → train tree₂ → update → repeat. EACH TREE FIXES THE PREVIOUS ERRORS: Tree 1 captures the main pattern. Tree 2 captures what tree 1 got wrong. Tree 3 captures what trees 1+2 got wrong. ... like a team of specialists, each fixing what the others miss. LEARNING RATE (lr): how much each tree contributes. lr=0.01: slow learning. Needs many trees (500+). Very stable. lr=0.1: good default. 100 trees usually enough. lr=1.0: fast but might overshoot (like GD with high lr). RULE: lr × n_estimators should be roughly constant. lr=0.1, n=100 ≈ lr=0.01, n=1000 (same complexity, latter is slightly better). WHY GB WINS KAGGLE: On tabular data, GB (XGBoost/LightGBM) beats deep learning ~80% of the time. Handles missing values, categorical features, non-linear interactions. The staged_score plot shows accuracy at each iteration — you can see exactly when adding more trees stops helping (early stopping). BREAST CANCER: 'worst concave points' + 'worst area' are usually top features. These are medical measurements — GB finds the most predictive ones automatically.
-
Change learning_rate from 0.1 to 0.01→ slower learning — needs more trees for same accuracy -
Change learning_rate from 0.1 to 1.0→ fast but unstable — test accuracy might drop -
Add max_depth=3 to the model→ deeper trees — more complex, might overfit -
Add subsample=0.8→ stochastic gradient boosting — each tree sees 80% of data, reduces overfitting