Gradient Boosting for Classification

hard
Unit 19 · Trees & Boosting0/0 to milestone

Gradient boosting for binary classification works in log-odds space. Start from F0=log⁡yˉ1−yˉF_0 = \log\frac{\bar y}{1 - \bar y}; each round:

  1. residuals r=y−σ(F)r = y - \sigma(F)
  2. fit a regression stump to the residuals: try every feature and every midpoint between consecutive distinct sorted values, splitting into x <= t and x > t, and keep the split with the lowest squared error of the residuals around each side's mean (ties: lower feature, then lower threshold)
  3. set each leaf's value with a Newton step: γ=∑r∑p(1−p)\gamma = \frac{\sum r}{\sum p(1-p)} over the leaf's samples
  4. F←F+η γleaf(x)F \leftarrow F + \eta\,\gamma_{\text{leaf}(x)}
Pro problem

Unlock this and every premium problem across all tracks — plus hidden-test grading, advanced AI engineering modules and new content every week.

Start 7-day free trial
solution.py · Python 3.13
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Gradient Boosting for Classification · TechGradify