Boosting is covered in section 8.2.3 of An Introduction to Statistical Learning , and its
classic example is AdaBoost. Boosted trees (the XGBoost and LightGBM family) are among the most common models in
banking today for tabular data, so it is worth knowing what they do.
Bagging vs boosting in one picture
data, mistakes up-weighted
data, mistakes up-weighted
Item Bagging / random forest Boosting How trees are trained independently, in parallel one after another What each tree sees a random resample the previous trees’ mistakes Typical trees deep (low bias, high variance) shallow (high bias, low variance) What it reduces variance mainly bias Risk can’t overfit by adding trees can overfit if you add too many
In the bias and variance terms: bagging takes complex,
unstable models and steadies them. Boosting takes simple, stable models and makes them smarter.
AdaBoost: reweight the mistakes
AdaBoost (adaptive boosting, Freund and Schapire, 1997) was the first widely used boosting method.
Give every training example the same weight.
Train a weak model, often a stump : a tree with a single question.
Measure its weighted error ε \risk{\varepsilon} ε : the total weight of the examples it got wrong.
Give the model a vote α \key{\alpha} α : the lower its error, the bigger its say.
Increase the weight of the examples it got wrong, decrease the rest, and repeat from step 2.
The final prediction is a weighted vote of all the models.
α, the model's vote ε, its weighted error wrong examples right examples
The vote of model t t t :
α t = 1 2 ln ( 1 − ε t ε t ) \key{\alpha_t} = \frac{1}{2} \ln\!\left(\frac{1 - \risk{\varepsilon_t}}{\risk{\varepsilon_t}}\right) α t = 2 1 ln ( ε t 1 − ε t )
If ε t = 0.5 \risk{\varepsilon_t} = 0.5 ε t = 0.5 (a coin flip), α t = 0 \key{\alpha_t} = 0 α t = 0 : no say. The smaller the error, the larger
α t \key{\alpha_t} α t .
The weight update for each example i i i , depending on whether model t t t got it wrong or right :
w i ← w i × { e α t if wrong e − α t if right w_i \leftarrow w_i \times
\begin{cases}
\bad{e^{\key{\alpha_t}}} & \bad{\text{if wrong}} \\
\good{e^{-\key{\alpha_t}}} & \good{\text{if right}}
\end{cases} w i ← w i × { e α t e − α t if wrong if right
Then all the weights are divided by their total, so they add up to 1 again.
Worked example: one round, ten trades
Ten trades, each with weight 0.1. The first stump gets 3 of them wrong :
ε = 3 × 0.1 = 0.3 \begin{aligned}
\risk{\varepsilon} &= 3 \times 0.1 \\
&= \risk{0.3}
\end{aligned} ε = 3 × 0.1 = 0.3
α = 1 2 ln ( 0.7 0.3 ) = 0.4236 \begin{aligned}
\key{\alpha} &= \tfrac{1}{2} \ln\!\left(\tfrac{0.7}{\risk{0.3}}\right) \\
&= \key{0.4236}
\end{aligned} α = 2 1 ln ( 0.3 0.7 ) = 0.4236
wrong trades are multiplied by e 0.4236 = 1.5275 \bad{e^{\key{0.4236}}} = 1.5275 e 0.4236 = 1.5275 , right ones by e − 0.4236 = 0.6547 \good{e^{-\key{0.4236}}} = 0.6547 e − 0.4236 = 0.6547 :
Item Before × factor Unnormalised After normalising (÷ 0.9165) Each wrong trade (3) 0.1 1.5275 0.15275 0.1667 Each right trade (7) 0.1 0.6547 0.06547 0.0714
After one round, the 3 wrong trades carry half the total weight (3 × 0.1667 = 0.5), and the 7
right ones the other half. That’s always true after an AdaBoost update: the next model is forced to
treat the previous model’s mistakes as half of its whole problem.
Notation in other books
Murphy’s Probabilistic Machine Learning: An Introduction (chapter 18, on boosting) writes the
same algorithm slightly differently. He calls the vote β m = 1 2 ln ( ( 1 − err m ) / err m ) \key{\beta_m} = \tfrac{1}{2}\ln\big((1 - \risk{\text{err}_m}) / \risk{\text{err}_m}\big) β m = 2 1 ln ( ( 1 − err m ) / err m ) ,
and only multiplies the wrong examples, by e α m \bad{e^{\key{\alpha_m}}} e α m with α m = 2 β m \key{\alpha_m} = 2\key{\beta_m} α m = 2 β m , before
normalising. That’s the same result: either way, a wrong example ends up e 2 β e^{2\key{\beta}} e 2 β times heavier
than a right one.
A note on scikit-learn’s numbers
scikit-learn’s AdaBoostClassifier (version 1.9) uses the SAMME form of the algorithm. With two
classes, the weight it reports is
α t = ln ( 1 − ε t ε t ) \key{\alpha_t} = \ln\!\left(\frac{1 - \risk{\varepsilon_t}}{\risk{\varepsilon_t}}\right) α t = ln ( ε t 1 − ε t )
without the 1 2 \tfrac{1}{2} 2 1 . That’s exactly Murphy’s α m = 2 β m \key{\alpha_m} = 2\key{\beta_m} α m = 2 β m . Every vote is twice as
big, so the final ranking of predictions is the same; only the printed numbers differ. If you
compare a textbook with ada.estimator_weights_, that’s why.
What AdaBoost did on the stress-month data
I boosted stumps on the 3,685 training rows (2019 to 2021) of the
stress-month problem : will the next 20 days’
volatility be above 30%? Only 20.5% of months are, so accuracy is misleading (saying “calm”
every time scores 77.4% on the test months); that’s why the scores below are AUC. Boosting
libraries also offer class weights (scale_pos_weight in XGBoost) for imbalance like this. The
first three rounds:
Round Stump’s question Weighted error scikit-learn weight 1 20-day volatility? 0.1414 1.8038 2 20-day volatility? (a different cut-off) 0.3865 0.4620 3 Price vs 20-day average? 0.3135 0.7837
Round 1’s stump gets the easy cases : one cut on 20-day volatility is wrong on 14.1 % \risk{14.1\%} 14.1%
of the weight, far better than the 20.5% of calling everything calm. AdaBoost then gives the
months it got wrong, mostly stress months that followed a calm one, half the total weight,
which forces round 2 to look at them.
Round 2 asks about the same feature at a different cut-off and is wrong on 38.7% of the
reweighted problem, so it earns a small vote. Round 3 moves to the price against its moving
average. Each round fixes a part of what the earlier ones missed, and each gets a vote sized by
how well it did on its version of the problem.
A single stump scores an AUC of 0.608 on the test months. Boosting 78 of them reaches 0.795 \key{0.795} 0.795 .
Gradient boosting: fit the leftover error
Gradient boosting (Friedman, 2001) generalises the idea. Instead of reweighting examples, each
new tree is trained to predict what the current model still gets wrong .
For regression with squared error, that’s literally the residuals. An Introduction to
Statistical Learning gives it as Algorithm 8.2. Start with f ^ ( x ) = 0 \hat{f}(x) = 0 f ^ ( x ) = 0 and residuals
r i = y i \risk{r_i} = y_i r i = y i . Then, for each round b = 1 , 2 , … , B b = 1, 2, \dots, B b = 1 , 2 , … , B , fit a small tree f ^ b \hat{f}^b f ^ b to the residuals
and update:
λ, how much of each tree is added r, the error left
f ^ ( x ) ← f ^ ( x ) + λ f ^ b ( x ) (8.10) r i ← r i − λ f ^ b ( x i ) (8.11) \begin{aligned}
\hat{f}(x) &\leftarrow \hat{f}(x) + \key{\lambda} \hat{f}^b(x) & \text{(8.10)} \\
\risk{r_i} &\leftarrow \risk{r_i} - \key{\lambda} \hat{f}^b(x_i) & \text{(8.11)}
\end{aligned} f ^ ( x ) r i ← f ^ ( x ) + λ f ^ b ( x ) ← r i − λ f ^ b ( x i ) (8.10) (8.11)
The final model is the sum of all the shrunken trees:
f ^ ( x ) = ∑ b = 1 B λ f ^ b ( x ) (8.12) \hat{f}(x) = \sum_{b=1}^{B} \key{\lambda} \hat{f}^b(x) \qquad \text{(8.12)} f ^ ( x ) = b = 1 ∑ B λ f ^ b ( x ) (8.12)
Symbol Meaning f ^ ( x ) \hat{f}(x) f ^ ( x ) the model so far r i \risk{r_i} r i the residuals : what’s still unexplained for example i i i f ^ b \hat{f}^b f ^ b the small tree added in round b b b , trained to predict the residuals λ \key{\lambda} λ the shrinkage or learning rate , a small number like 0.1 (ISLP suggests 0.01 or 0.001) B B B the number of trees
Plain meaning: start with a rough guess. Look at the errors. Train a small tree to predict the
errors. Add a fraction of it to the guess. Repeat. For other losses, like the log loss used for
classification, “residuals” become the negative gradient of the loss (often called
pseudo-residuals), which gives the method its name.
The idea is the same.
The learning rate λ \key{\lambda} λ matters a lot. Each tree only corrects part of the error, so no single tree
can push the model too far:
{"panels":[{"x0":52.28,"x1":565.2,"y0":29.16,"y1":232.48,"title":"Test score as trees are added (dot = round chosen on validation)","xlabel":"Number of trees in the model","ylabel":"Test AUC, 2022\u20132023 (0.5 = coin flip, 1 = perfect)","xlog":false}],"series":[{"panel":0,"label":"AdaBoost, stumps","color":"var(--chart-blue, #3b6ea5)","x":[1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,21.0,22.0,23.0,24.0,25.0,26.0,27.0,28.0,29.0,30.0,31.0,32.0,33.0,34.0,35.0,36.0,37.0,38.0,39.0,40.0,41.0,42.0,43.0,44.0,45.0,46.0,47.0,48.0,49.0,50.0,51.0,52.0,53.0,54.0,55.0,56.0,57.0,58.0,59.0,60.0,61.0,62.0,63.0,64.0,65.0,66.0,67.0,68.0,69.0,70.0,71.0,72.0,73.0,74.0,75.0,76.0,77.0,78.0,79.0,80.0,81.0,82.0,83.0,84.0,85.0,86.0,87.0,88.0,89.0,90.0,91.0,92.0,93.0,94.0,95.0,96.0,97.0,98.0,99.0,100.0,101.0,102.0,103.0,104.0,105.0,106.0,107.0,108.0,109.0,110.0,111.0,112.0,113.0,114.0,115.0,116.0,117.0,118.0,119.0,120.0,121.0,122.0,123.0,124.0,125.0,126.0,127.0,128.0,129.0,130.0,131.0,132.0,133.0,134.0,135.0,136.0,137.0,138.0,139.0,140.0,141.0,142.0,143.0,144.0,145.0,146.0,147.0,148.0,149.0,150.0,151.0,152.0,153.0,154.0,155.0,156.0,157.0,158.0,159.0,160.0,161.0,162.0,163.0,164.0,165.0,166.0,167.0,168.0,169.0,170.0,171.0,172.0,173.0,174.0,175.0,176.0,177.0,178.0,179.0,180.0,181.0,182.0,183.0,184.0,185.0,186.0,187.0,188.0,189.0,190.0,191.0,192.0,193.0,194.0,195.0,196.0,197.0,198.0,199.0,200.0,201.0,202.0,203.0,204.0,205.0,206.0,207.0,208.0,209.0,210.0,211.0,212.0,213.0,214.0,215.0,216.0,217.0,218.0,219.0,220.0,221.0,222.0,223.0,224.0,225.0,226.0,227.0,228.0,229.0,230.0,231.0,232.0,233.0,234.0,235.0,236.0,237.0,238.0,239.0,240.0,241.0,242.0,243.0,244.0,245.0,246.0,247.0,248.0,249.0,250.0,251.0,252.0,253.0,254.0,255.0,256.0,257.0,258.0,259.0,260.0,261.0,262.0,263.0,264.0,265.0,266.0,267.0,268.0,269.0,270.0,271.0,272.0,273.0,274.0,275.0,276.0,277.0,278.0,279.0,280.0,281.0,282.0,283.0,284.0,285.0,286.0,287.0,288.0,289.0,290.0,291.0,292.0,293.0,294.0,295.0,296.0,297.0,298.0,299.0,300.0],"y":[0.56339,0.723498,0.748239,0.74887,0.756741,0.756741,0.756652,0.756652,0.756652,0.756079,0.759062,0.759062,0.759229,0.759229,0.759229,0.759229,0.756223,0.788492,0.788492,0.788484,0.788481,0.788481,0.79157,0.79119,0.793287,0.793287,0.793124,0.791319,0.791319,0.791319,0.791319,0.791325,0.791325,0.791325,0.791325,0.79133,0.79133,0.79133,0.79133,0.7915,0.7915,0.791488,0.791488,0.791488,0.791488,0.791471,0.792171,0.792171,0.79218,0.79218,0.79218,0.79218,0.79217,0.79217,0.79217,0.79217,0.792162,0.791576,0.793979,0.791723,0.792804,0.792804,0.792804,0.792806,0.792806,0.792803,0.792803,0.792803,0.792803,0.792775,0.792775,0.792775,0.783001,0.782889,0.785292,0.781107,0.77573,0.794605,0.794279,0.794279,0.794206,0.794206,0.794206,0.792999,0.792999,0.792999,0.792999,0.792999,0.792992,0.792992,0.793006,0.793006,0.793006,0.793006,0.793006,0.793006,0.793032,0.794361,0.794361,0.794538,0.794538,0.794526,0.794526,0.794526,0.794526,0.794526,0.794526,0.794526,0.794526,0.794525,0.794525,0.794524,0.794524,0.794517,0.794517,0.794514,0.794514,0.794506,0.794506,0.794506,0.794506,0.794512,0.794512,0.794507,0.794507,0.794507,0.794507,0.794528,0.794528,0.794522,0.794522,0.794501,0.794501,0.79443,0.79443,0.79443,0.79443,0.79443,0.79443,0.794429,0.794429,0.794429,0.794429,0.794429,0.794429,0.794428,0.794428,0.794455,0.794455,0.794446,0.794446,0.794434,0.794434,0.794434,0.794434,0.794435,0.794435,0.794435,0.794435,0.79443,0.792523,0.79485,0.794038,0.794453,0.794733,0.792539,0.792463,0.792463,0.792484,0.79245,0.792428,0.792428,0.792431,0.792431,0.792432,0.792432,0.792432,0.792432,0.792432,0.792432,0.792429,0.792429,0.792429,0.792429,0.792425,0.792425,0.792424,0.792424,0.792424,0.792424,0.792405,0.792405,0.792408,0.792395,0.792368,0.792368,0.792363,0.792363,0.792372,0.792328,0.792328,0.792322,0.792322,0.792322,0.792322,0.792318,0.792318,0.792321,0.792321,0.792321,0.792307,0.792267,0.791159,0.791159,0.791154,0.791154,0.791154,0.791154,0.791153,0.791153,0.791153,0.791153,0.791148,0.791283,0.791287,0.791287,0.791282,0.791282,0.791266,0.791263,0.789922,0.789897,0.789897,0.789895,0.789895,0.789891,0.789891,0.789887,0.789887,0.789887,0.789887,0.789882,0.789882,0.789882,0.789882,0.789868,0.789868,0.789852,0.789812,0.789779,0.789743,0.789743,0.789743,0.789743,0.789744,0.789673,0.789666,0.789666,0.789665,0.789665,0.789665,0.789665,0.789668,0.789668,0.789668,0.789668,0.789666,0.789573,0.78957,0.78957,0.789556,0.789556,0.789556,0.789513,0.789516,0.789484,0.789439,0.789439,0.789431,0.789431,0.789431,0.789373,0.789361,0.789361,0.789361,0.789357,0.789357,0.789375,0.789375,0.789373,0.789373,0.789376,0.789375,0.789385,0.78936,0.78935,0.78935,0.78935,0.78935,0.78935],"sx":[75.6,77.16,78.72,80.28,81.83,83.39,84.95,86.51,88.07,89.63,91.19,92.75,94.31,95.87,97.43,98.99,100.55,102.11,103.67,105.23,106.79,108.35,109.91,111.47,113.02,114.58,116.14,117.7,119.26,120.82,122.38,123.94,125.5,127.06,128.62,130.18,131.74,133.3,134.86,136.42,137.98,139.54,141.1,142.66,144.21,145.77,147.33,148.89,150.45,152.01,153.57,155.13,156.69,158.25,159.81,161.37,162.93,164.49,166.05,167.61,169.17,170.73,172.29,173.84,175.4,176.96,178.52,180.08,181.64,183.2,184.76,186.32,187.88,189.44,191.0,192.56,194.12,195.68,197.24,198.8,200.36,201.92,203.48,205.03,206.59,208.15,209.71,211.27,212.83,214.39,215.95,217.51,219.07,220.63,222.19,223.75,225.31,226.87,228.43,229.99,231.55,233.11,234.67,236.22,237.78,239.34,240.9,242.46,244.02,245.58,247.14,248.7,250.26,251.82,253.38,254.94,256.5,258.06,259.62,261.18,262.74,264.3,265.86,267.41,268.97,270.53,272.09,273.65,275.21,276.77,278.33,279.89,281.45,283.01,284.57,286.13,287.69,289.25,290.81,292.37,293.93,295.49,297.04,298.6,300.16,301.72,303.28,304.84,306.4,307.96,309.52,311.08,312.64,314.2,315.76,317.32,318.88,320.44,322.0,323.56,325.12,326.68,328.23,329.79,331.35,332.91,334.47,336.03,337.59,339.15,340.71,342.27,343.83,345.39,346.95,348.51,350.07,351.63,353.19,354.75,356.31,357.87,359.42,360.98,362.54,364.1,365.66,367.22,368.78,370.34,371.9,373.46,375.02,376.58,378.14,379.7,381.26,382.82,384.38,385.94,387.5,389.06,390.61,392.17,393.73,395.29,396.85,398.41,399.97,401.53,403.09,404.65,406.21,407.77,409.33,410.89,412.45,414.01,415.57,417.13,418.69,420.25,421.8,423.36,424.92,426.48,428.04,429.6,431.16,432.72,434.28,435.84,437.4,438.96,440.52,442.08,443.64,445.2,446.76,448.32,449.88,451.43,452.99,454.55,456.11,457.67,459.23,460.79,462.35,463.91,465.47,467.03,468.59,470.15,471.71,473.27,474.83,476.39,477.95,479.51,481.07,482.62,484.18,485.74,487.3,488.86,490.42,491.98,493.54,495.1,496.66,498.22,499.78,501.34,502.9,504.46,506.02,507.58,509.14,510.7,512.26,513.81,515.37,516.93,518.49,520.05,521.61,523.17,524.73,526.29,527.85,529.41,530.97,532.53,534.09,535.65,537.21,538.77,540.33,541.89],"sy":[200.26,118.87,106.3,105.98,101.98,101.98,102.02,102.02,102.02,102.31,100.8,100.8,100.71,100.71,100.71,100.71,102.24,85.84,85.84,85.84,85.84,85.84,84.27,84.47,83.4,83.4,83.48,84.4,84.4,84.4,84.4,84.4,84.4,84.4,84.4,84.39,84.39,84.39,84.39,84.31,84.31,84.31,84.31,84.31,84.31,84.32,83.97,83.97,83.96,83.96,83.96,83.96,83.97,83.97,83.97,83.97,83.97,84.27,83.05,84.19,83.65,83.65,83.65,83.64,83.64,83.65,83.65,83.65,83.65,83.66,83.66,83.66,88.63,88.68,87.46,89.59,92.32,82.73,82.9,82.9,82.93,82.93,82.93,83.55,83.55,83.55,83.55,83.55,83.55,83.55,83.54,83.54,83.54,83.54,83.54,83.54,83.53,82.85,82.85,82.76,82.76,82.77,82.77,82.77,82.77,82.77,82.77,82.77,82.77,82.77,82.77,82.77,82.77,82.77,82.77,82.78,82.78,82.78,82.78,82.78,82.78,82.78,82.78,82.78,82.78,82.78,82.78,82.77,82.77,82.77,82.77,82.78,82.78,82.82,82.82,82.82,82.82,82.82,82.82,82.82,82.82,82.82,82.82,82.82,82.82,82.82,82.82,82.81,82.81,82.81,82.81,82.82,82.82,82.82,82.82,82.82,82.82,82.82,82.82,82.82,83.79,82.61,83.02,82.81,82.66,83.78,83.82,83.82,83.81,83.82,83.84,83.84,83.84,83.84,83.83,83.83,83.83,83.83,83.83,83.83,83.84,83.84,83.84,83.84,83.84,83.84,83.84,83.84,83.84,83.84,83.85,83.85,83.85,83.85,83.87,83.87,83.87,83.87,83.86,83.89,83.89,83.89,83.89,83.89,83.89,83.89,83.89,83.89,83.89,83.89,83.9,83.92,84.48,84.48,84.48,84.48,84.48,84.48,84.48,84.48,84.48,84.48,84.49,84.42,84.42,84.42,84.42,84.42,84.43,84.43,85.11,85.12,85.12,85.12,85.12,85.13,85.13,85.13,85.13,85.13,85.13,85.13,85.13,85.13,85.13,85.14,85.14,85.15,85.17,85.18,85.2,85.2,85.2,85.2,85.2,85.24,85.24,85.24,85.24,85.24,85.24,85.24,85.24,85.24,85.24,85.24,85.24,85.29,85.29,85.29,85.3,85.3,85.3,85.32,85.32,85.33,85.36,85.36,85.36,85.36,85.36,85.39,85.4,85.4,85.4,85.4,85.4,85.39,85.39,85.39,85.39,85.39,85.39,85.38,85.4,85.4,85.4,85.4,85.4,85.4]},{"panel":0,"label":"gradient boosting, depth-3 trees, rate 0.1","color":"var(--chart-maroon, #b6262c)","x":[1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,21.0,22.0,23.0,24.0,25.0,26.0,27.0,28.0,29.0,30.0,31.0,32.0,33.0,34.0,35.0,36.0,37.0,38.0,39.0,40.0,41.0,42.0,43.0,44.0,45.0,46.0,47.0,48.0,49.0,50.0,51.0,52.0,53.0,54.0,55.0,56.0,57.0,58.0,59.0,60.0,61.0,62.0,63.0,64.0,65.0,66.0,67.0,68.0,69.0,70.0,71.0,72.0,73.0,74.0,75.0,76.0,77.0,78.0,79.0,80.0,81.0,82.0,83.0,84.0,85.0,86.0,87.0,88.0,89.0,90.0,91.0,92.0,93.0,94.0,95.0,96.0,97.0,98.0,99.0,100.0,101.0,102.0,103.0,104.0,105.0,106.0,107.0,108.0,109.0,110.0,111.0,112.0,113.0,114.0,115.0,116.0,117.0,118.0,119.0,120.0,121.0,122.0,123.0,124.0,125.0,126.0,127.0,128.0,129.0,130.0,131.0,132.0,133.0,134.0,135.0,136.0,137.0,138.0,139.0,140.0,141.0,142.0,143.0,144.0,145.0,146.0,147.0,148.0,149.0,150.0,151.0,152.0,153.0,154.0,155.0,156.0,157.0,158.0,159.0,160.0,161.0,162.0,163.0,164.0,165.0,166.0,167.0,168.0,169.0,170.0,171.0,172.0,173.0,174.0,175.0,176.0,177.0,178.0,179.0,180.0,181.0,182.0,183.0,184.0,185.0,186.0,187.0,188.0,189.0,190.0,191.0,192.0,193.0,194.0,195.0,196.0,197.0,198.0,199.0,200.0,201.0,202.0,203.0,204.0,205.0,206.0,207.0,208.0,209.0,210.0,211.0,212.0,213.0,214.0,215.0,216.0,217.0,218.0,219.0,220.0,221.0,222.0,223.0,224.0,225.0,226.0,227.0,228.0,229.0,230.0,231.0,232.0,233.0,234.0,235.0,236.0,237.0,238.0,239.0,240.0,241.0,242.0,243.0,244.0,245.0,246.0,247.0,248.0,249.0,250.0,251.0,252.0,253.0,254.0,255.0,256.0,257.0,258.0,259.0,260.0,261.0,262.0,263.0,264.0,265.0,266.0,267.0,268.0,269.0,270.0,271.0,272.0,273.0,274.0,275.0,276.0,277.0,278.0,279.0,280.0,281.0,282.0,283.0,284.0,285.0,286.0,287.0,288.0,289.0,290.0,291.0,292.0,293.0,294.0,295.0,296.0,297.0,298.0,299.0,300.0],"y":[0.78452,0.801795,0.811448,0.815792,0.81646,0.817249,0.816558,0.816303,0.816452,0.816574,0.816437,0.816424,0.816088,0.816092,0.815925,0.815896,0.816359,0.815567,0.816567,0.815184,0.816219,0.813521,0.813451,0.813298,0.814413,0.812845,0.812931,0.816617,0.816285,0.816095,0.815847,0.816134,0.816113,0.816225,0.815565,0.815454,0.815663,0.816201,0.817073,0.817081,0.816932,0.816912,0.816907,0.816815,0.815855,0.815344,0.815245,0.815353,0.814093,0.813965,0.813329,0.813547,0.813556,0.813495,0.812323,0.811428,0.81171,0.812759,0.812094,0.812338,0.81075,0.809694,0.810348,0.810288,0.810439,0.810851,0.810682,0.810887,0.81115,0.810383,0.810337,0.810542,0.80995,0.809491,0.80938,0.808972,0.809487,0.808922,0.808932,0.808931,0.808925,0.809027,0.808626,0.809045,0.808981,0.80831,0.808246,0.808203,0.808288,0.807847,0.808264,0.808299,0.808252,0.807238,0.807154,0.807177,0.807238,0.806852,0.806718,0.807026,0.806678,0.806071,0.806023,0.805582,0.805471,0.805068,0.805573,0.805597,0.805505,0.804841,0.804674,0.804731,0.804367,0.804529,0.804313,0.804464,0.804102,0.80365,0.803592,0.803536,0.803632,0.802941,0.802999,0.802043,0.80193,0.801876,0.802059,0.802015,0.801302,0.800386,0.800388,0.800186,0.800055,0.799927,0.799801,0.799491,0.799201,0.799339,0.799349,0.799725,0.79987,0.799771,0.799798,0.799927,0.799649,0.799732,0.800007,0.79995,0.799684,0.799067,0.798967,0.798784,0.798096,0.798351,0.79813,0.798272,0.798192,0.79839,0.797435,0.797248,0.797176,0.797153,0.797184,0.797088,0.796817,0.796822,0.79679,0.796255,0.796288,0.796424,0.796234,0.796012,0.795571,0.795639,0.795558,0.795138,0.795154,0.794941,0.795037,0.795006,0.794912,0.794783,0.794783,0.794131,0.79413,0.794332,0.794369,0.794122,0.79357,0.79337,0.793322,0.793715,0.793563,0.793405,0.79302,0.792998,0.79339,0.793245,0.79292,0.792834,0.792328,0.792394,0.792993,0.792852,0.79288,0.793085,0.792673,0.792836,0.792753,0.792765,0.792526,0.792537,0.792577,0.792554,0.792551,0.792293,0.79201,0.791856,0.792087,0.791688,0.790851,0.790119,0.790286,0.789937,0.789964,0.789824,0.789971,0.789993,0.790203,0.790055,0.790134,0.790276,0.790686,0.790584,0.790483,0.790154,0.790106,0.789733,0.789817,0.789853,0.789678,0.789981,0.789432,0.789621,0.789883,0.789188,0.789094,0.788992,0.789318,0.789318,0.789004,0.789127,0.78898,0.788463,0.788415,0.788688,0.788929,0.788754,0.788899,0.788668,0.788434,0.788059,0.788023,0.787716,0.787661,0.787526,0.787427,0.788096,0.787983,0.787849,0.787816,0.787764,0.787604,0.786995,0.787223,0.787231,0.787274,0.787249,0.787355,0.787436,0.78755,0.787826,0.787637,0.787252,0.787024,0.787158,0.787315,0.787239,0.786943,0.787074,0.786959,0.787138,0.787209,0.787166,0.78704,0.787309,0.786948,0.786887,0.786577,0.786465],"sx":[75.6,77.16,78.72,80.28,81.83,83.39,84.95,86.51,88.07,89.63,91.19,92.75,94.31,95.87,97.43,98.99,100.55,102.11,103.67,105.23,106.79,108.35,109.91,111.47,113.02,114.58,116.14,117.7,119.26,120.82,122.38,123.94,125.5,127.06,128.62,130.18,131.74,133.3,134.86,136.42,137.98,139.54,141.1,142.66,144.21,145.77,147.33,148.89,150.45,152.01,153.57,155.13,156.69,158.25,159.81,161.37,162.93,164.49,166.05,167.61,169.17,170.73,172.29,173.84,175.4,176.96,178.52,180.08,181.64,183.2,184.76,186.32,187.88,189.44,191.0,192.56,194.12,195.68,197.24,198.8,200.36,201.92,203.48,205.03,206.59,208.15,209.71,211.27,212.83,214.39,215.95,217.51,219.07,220.63,222.19,223.75,225.31,226.87,228.43,229.99,231.55,233.11,234.67,236.22,237.78,239.34,240.9,242.46,244.02,245.58,247.14,248.7,250.26,251.82,253.38,254.94,256.5,258.06,259.62,261.18,262.74,264.3,265.86,267.41,268.97,270.53,272.09,273.65,275.21,276.77,278.33,279.89,281.45,283.01,284.57,286.13,287.69,289.25,290.81,292.37,293.93,295.49,297.04,298.6,300.16,301.72,303.28,304.84,306.4,307.96,309.52,311.08,312.64,314.2,315.76,317.32,318.88,320.44,322.0,323.56,325.12,326.68,328.23,329.79,331.35,332.91,334.47,336.03,337.59,339.15,340.71,342.27,343.83,345.39,346.95,348.51,350.07,351.63,353.19,354.75,356.31,357.87,359.42,360.98,362.54,364.1,365.66,367.22,368.78,370.34,371.9,373.46,375.02,376.58,378.14,379.7,381.26,382.82,384.38,385.94,387.5,389.06,390.61,392.17,393.73,395.29,396.85,398.41,399.97,401.53,403.09,404.65,406.21,407.77,409.33,410.89,412.45,414.01,415.57,417.13,418.69,420.25,421.8,423.36,424.92,426.48,428.04,429.6,431.16,432.72,434.28,435.84,437.4,438.96,440.52,442.08,443.64,445.2,446.76,448.32,449.88,451.43,452.99,454.55,456.11,457.67,459.23,460.79,462.35,463.91,465.47,467.03,468.59,470.15,471.71,473.27,474.83,476.39,477.95,479.51,481.07,482.62,484.18,485.74,487.3,488.86,490.42,491.98,493.54,495.1,496.66,498.22,499.78,501.34,502.9,504.46,506.02,507.58,509.14,510.7,512.26,513.81,515.37,516.93,518.49,520.05,521.61,523.17,524.73,526.29,527.85,529.41,530.97,532.53,534.09,535.65,537.21,538.77,540.33,541.89],"sy":[87.86,79.08,74.17,71.96,71.62,71.22,71.57,71.7,71.62,71.56,71.63,71.64,71.81,71.81,71.89,71.91,71.67,72.07,71.57,72.27,71.74,73.11,73.15,73.23,72.66,73.46,73.41,71.54,71.71,71.81,71.93,71.79,71.8,71.74,72.08,72.13,72.03,71.75,71.31,71.31,71.38,71.39,71.39,71.44,71.93,72.19,72.24,72.18,72.82,72.89,73.21,73.1,73.1,73.13,73.72,74.18,74.04,73.5,73.84,73.72,74.52,75.06,74.73,74.76,74.68,74.47,74.56,74.45,74.32,74.71,74.73,74.63,74.93,75.16,75.22,75.43,75.17,75.45,75.45,75.45,75.45,75.4,75.6,75.39,75.42,75.76,75.8,75.82,75.77,76.0,75.79,75.77,75.79,76.31,76.35,76.34,76.31,76.5,76.57,76.42,76.59,76.9,76.93,77.15,77.21,77.41,77.15,77.14,77.19,77.53,77.61,77.58,77.77,77.69,77.8,77.72,77.9,78.13,78.16,78.19,78.14,78.49,78.46,78.95,79.01,79.03,78.94,78.96,79.33,79.79,79.79,79.89,79.96,80.02,80.09,80.25,80.39,80.32,80.32,80.13,80.05,80.1,80.09,80.02,80.17,80.12,79.98,80.01,80.15,80.46,80.51,80.61,80.96,80.83,80.94,80.87,80.91,80.81,81.29,81.39,81.42,81.43,81.42,81.47,81.61,81.6,81.62,81.89,81.87,81.81,81.9,82.01,82.24,82.2,82.25,82.46,82.45,82.56,82.51,82.53,82.57,82.64,82.64,82.97,82.97,82.87,82.85,82.98,83.26,83.36,83.38,83.18,83.26,83.34,83.54,83.55,83.35,83.42,83.59,83.63,83.89,83.85,83.55,83.62,83.61,83.5,83.71,83.63,83.67,83.66,83.79,83.78,83.76,83.77,83.77,83.9,84.05,84.13,84.01,84.21,84.64,85.01,84.93,85.1,85.09,85.16,85.09,85.07,84.97,85.04,85.0,84.93,84.72,84.77,84.83,84.99,85.02,85.21,85.16,85.14,85.23,85.08,85.36,85.26,85.13,85.48,85.53,85.58,85.42,85.42,85.58,85.51,85.59,85.85,85.88,85.74,85.61,85.7,85.63,85.75,85.87,86.06,86.08,86.23,86.26,86.33,86.38,86.04,86.1,86.16,86.18,86.21,86.29,86.6,86.48,86.48,86.46,86.47,86.41,86.37,86.32,86.18,86.27,86.47,86.58,86.52,86.44,86.47,86.62,86.56,86.62,86.53,86.49,86.51,86.57,86.44,86.62,86.65,86.81,86.87]},{"panel":0,"label":"gradient boosting, depth-3 trees, rate 1.0","color":"#e0676b","x":[1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,21.0,22.0,23.0,24.0,25.0,26.0,27.0,28.0,29.0,30.0,31.0,32.0,33.0,34.0,35.0,36.0,37.0,38.0,39.0,40.0,41.0,42.0,43.0,44.0,45.0,46.0,47.0,48.0,49.0,50.0,51.0,52.0,53.0,54.0,55.0,56.0,57.0,58.0,59.0,60.0,61.0,62.0,63.0,64.0,65.0,66.0,67.0,68.0,69.0,70.0,71.0,72.0,73.0,74.0,75.0,76.0,77.0,78.0,79.0,80.0,81.0,82.0,83.0,84.0,85.0,86.0,87.0,88.0,89.0,90.0,91.0,92.0,93.0,94.0,95.0,96.0,97.0,98.0,99.0,100.0,101.0,102.0,103.0,104.0,105.0,106.0,107.0,108.0,109.0,110.0,111.0,112.0,113.0,114.0,115.0,116.0,117.0,118.0,119.0,120.0,121.0,122.0,123.0,124.0,125.0,126.0,127.0,128.0,129.0,130.0,131.0,132.0,133.0,134.0,135.0,136.0,137.0,138.0,139.0,140.0,141.0,142.0,143.0,144.0,145.0,146.0,147.0,148.0,149.0,150.0,151.0,152.0,153.0,154.0,155.0,156.0,157.0,158.0,159.0,160.0,161.0,162.0,163.0,164.0,165.0,166.0,167.0,168.0,169.0,170.0,171.0,172.0,173.0,174.0,175.0,176.0,177.0,178.0,179.0,180.0,181.0,182.0,183.0,184.0,185.0,186.0,187.0,188.0,189.0,190.0,191.0,192.0,193.0,194.0,195.0,196.0,197.0,198.0,199.0,200.0,201.0,202.0,203.0,204.0,205.0,206.0,207.0,208.0,209.0,210.0,211.0,212.0,213.0,214.0,215.0,216.0,217.0,218.0,219.0,220.0,221.0,222.0,223.0,224.0,225.0,226.0,227.0,228.0,229.0,230.0,231.0,232.0,233.0,234.0,235.0,236.0,237.0,238.0,239.0,240.0,241.0,242.0,243.0,244.0,245.0,246.0,247.0,248.0,249.0,250.0,251.0,252.0,253.0,254.0,255.0,256.0,257.0,258.0,259.0,260.0,261.0,262.0,263.0,264.0,265.0,266.0,267.0,268.0,269.0,270.0,271.0,272.0,273.0,274.0,275.0,276.0,277.0,278.0,279.0,280.0,281.0,282.0,283.0,284.0,285.0,286.0,287.0,288.0,289.0,290.0,291.0,292.0,293.0,294.0,295.0,296.0,297.0,298.0,299.0,300.0],"y":[0.78452,0.791316,0.801884,0.775008,0.791929,0.782339,0.774382,0.774641,0.775366,0.769691,0.752223,0.756837,0.757965,0.750836,0.748182,0.739939,0.733155,0.732547,0.744567,0.735315,0.729285,0.739,0.738937,0.743398,0.741441,0.744575,0.743547,0.742725,0.744874,0.745785,0.747772,0.737681,0.737592,0.731672,0.733621,0.728943,0.727326,0.727036,0.72514,0.723408,0.723925,0.725364,0.722708,0.724556,0.728704,0.718086,0.719512,0.719809,0.720797,0.719472,0.719309,0.714124,0.718543,0.71679,0.720428,0.720907,0.719315,0.7191,0.71925,0.720696,0.721098,0.724435,0.722333,0.727909,0.726992,0.727542,0.725407,0.725597,0.726306,0.731029,0.730994,0.730084,0.73161,0.734603,0.738362,0.737657,0.7389,0.739756,0.738105,0.739363,0.740074,0.740682,0.740798,0.74252,0.745675,0.744736,0.744919,0.743745,0.743006,0.739497,0.742928,0.744111,0.742319,0.744126,0.743424,0.743188,0.743356,0.742189,0.741632,0.744284,0.742262,0.742991,0.742748,0.743158,0.743498,0.742701,0.742782,0.742192,0.742454,0.740265,0.739483,0.738857,0.739781,0.739951,0.739103,0.739922,0.739578,0.74026,0.738089,0.739499,0.739443,0.739291,0.739138,0.738869,0.738492,0.737693,0.738182,0.739298,0.739218,0.741552,0.741844,0.74023,0.740034,0.740713,0.740628,0.740597,0.738224,0.740979,0.741012,0.73985,0.740121,0.740552,0.739875,0.740402,0.739298,0.738486,0.739962,0.742193,0.741781,0.741938,0.741012,0.741462,0.741148,0.740842,0.740675,0.73983,0.739436,0.740384,0.740195,0.740913,0.7406,0.741143,0.742351,0.742637,0.742956,0.743552,0.74466,0.743956,0.745061,0.745411,0.746409,0.745839,0.746161,0.745711,0.744345,0.742775,0.743044,0.742813,0.74379,0.743683,0.743614,0.744987,0.746401,0.743556,0.743102,0.743352,0.743303,0.744324,0.744211,0.744237,0.743586,0.743031,0.744791,0.743863,0.743796,0.743135,0.742432,0.74173,0.740011,0.739575,0.739928,0.739436,0.739765,0.739758,0.739731,0.739306,0.742303,0.742775,0.743495,0.742466,0.742834,0.742404,0.74263,0.742899,0.74407,0.743722,0.743171,0.744463,0.742625,0.742321,0.742101,0.742145,0.742497,0.742204,0.742701,0.743074,0.743129,0.74249,0.742228,0.741314,0.741607,0.741986,0.739865,0.740735,0.74129,0.742051,0.741725,0.741349,0.740952,0.741422,0.741372,0.741599,0.741822,0.740863,0.740851,0.743087,0.742449,0.742617,0.743425,0.742022,0.742126,0.742179,0.741427,0.742478,0.742493,0.742051,0.742373,0.742069,0.741666,0.74206,0.741924,0.743324,0.743252,0.744953,0.744886,0.744823,0.744499,0.745633,0.744347,0.743883,0.743314,0.741996,0.741713,0.741498,0.741154,0.741611,0.741196,0.741657,0.740616,0.740514,0.740024,0.740401,0.740783,0.742482,0.742651,0.742418,0.742167,0.742051,0.741761,0.740211,0.740306,0.740136,0.739853,0.739597,0.740271,0.739275,0.740513,0.738721,0.738771,0.738679],"sx":[75.6,77.16,78.72,80.28,81.83,83.39,84.95,86.51,88.07,89.63,91.19,92.75,94.31,95.87,97.43,98.99,100.55,102.11,103.67,105.23,106.79,108.35,109.91,111.47,113.02,114.58,116.14,117.7,119.26,120.82,122.38,123.94,125.5,127.06,128.62,130.18,131.74,133.3,134.86,136.42,137.98,139.54,141.1,142.66,144.21,145.77,147.33,148.89,150.45,152.01,153.57,155.13,156.69,158.25,159.81,161.37,162.93,164.49,166.05,167.61,169.17,170.73,172.29,173.84,175.4,176.96,178.52,180.08,181.64,183.2,184.76,186.32,187.88,189.44,191.0,192.56,194.12,195.68,197.24,198.8,200.36,201.92,203.48,205.03,206.59,208.15,209.71,211.27,212.83,214.39,215.95,217.51,219.07,220.63,222.19,223.75,225.31,226.87,228.43,229.99,231.55,233.11,234.67,236.22,237.78,239.34,240.9,242.46,244.02,245.58,247.14,248.7,250.26,251.82,253.38,254.94,256.5,258.06,259.62,261.18,262.74,264.3,265.86,267.41,268.97,270.53,272.09,273.65,275.21,276.77,278.33,279.89,281.45,283.01,284.57,286.13,287.69,289.25,290.81,292.37,293.93,295.49,297.04,298.6,300.16,301.72,303.28,304.84,306.4,307.96,309.52,311.08,312.64,314.2,315.76,317.32,318.88,320.44,322.0,323.56,325.12,326.68,328.23,329.79,331.35,332.91,334.47,336.03,337.59,339.15,340.71,342.27,343.83,345.39,346.95,348.51,350.07,351.63,353.19,354.75,356.31,357.87,359.42,360.98,362.54,364.1,365.66,367.22,368.78,370.34,371.9,373.46,375.02,376.58,378.14,379.7,381.26,382.82,384.38,385.94,387.5,389.06,390.61,392.17,393.73,395.29,396.85,398.41,399.97,401.53,403.09,404.65,406.21,407.77,409.33,410.89,412.45,414.01,415.57,417.13,418.69,420.25,421.8,423.36,424.92,426.48,428.04,429.6,431.16,432.72,434.28,435.84,437.4,438.96,440.52,442.08,443.64,445.2,446.76,448.32,449.88,451.43,452.99,454.55,456.11,457.67,459.23,460.79,462.35,463.91,465.47,467.03,468.59,470.15,471.71,473.27,474.83,476.39,477.95,479.51,481.07,482.62,484.18,485.74,487.3,488.86,490.42,491.98,493.54,495.1,496.66,498.22,499.78,501.34,502.9,504.46,506.02,507.58,509.14,510.7,512.26,513.81,515.37,516.93,518.49,520.05,521.61,523.17,524.73,526.29,527.85,529.41,530.97,532.53,534.09,535.65,537.21,538.77,540.33,541.89],"sy":[87.86,84.4,79.03,92.69,84.09,88.96,93.01,92.88,92.51,95.39,104.27,101.93,101.35,104.98,106.33,110.52,113.96,114.27,108.16,112.87,115.93,110.99,111.03,108.76,109.75,108.16,108.68,109.1,108.01,107.54,106.54,111.66,111.71,114.72,113.73,116.11,116.93,117.07,118.04,118.92,118.66,117.92,119.27,118.34,116.23,121.62,120.9,120.75,120.25,120.92,121.0,123.64,121.39,122.28,120.43,120.19,121.0,121.11,121.03,120.3,120.09,118.4,119.47,116.63,117.1,116.82,117.9,117.81,117.45,115.05,115.06,115.53,114.75,113.23,111.32,111.68,111.04,110.61,111.45,110.81,110.45,110.14,110.08,109.2,107.6,108.08,107.98,108.58,108.96,110.74,109.0,108.4,109.31,108.39,108.74,108.86,108.78,109.37,109.66,108.31,109.34,108.97,109.09,108.88,108.71,109.11,109.07,109.37,109.24,110.35,110.75,111.07,110.6,110.51,110.94,110.53,110.7,110.35,111.46,110.74,110.77,110.85,110.92,111.06,111.25,111.66,111.41,110.84,110.88,109.7,109.55,110.37,110.47,110.12,110.17,110.18,111.39,109.99,109.97,110.56,110.42,110.2,110.55,110.28,110.84,111.26,110.5,109.37,109.58,109.5,109.97,109.74,109.9,110.06,110.14,110.57,110.77,110.29,110.39,110.02,110.18,109.9,109.29,109.15,108.98,108.68,108.12,108.47,107.91,107.73,107.23,107.52,107.35,107.58,108.28,109.07,108.94,109.06,108.56,108.61,108.65,107.95,107.23,108.68,108.91,108.78,108.81,108.29,108.34,108.33,108.66,108.94,108.05,108.52,108.56,108.89,109.25,109.61,110.48,110.7,110.52,110.77,110.6,110.61,110.62,110.84,109.31,109.07,108.71,109.23,109.04,109.26,109.15,109.01,108.42,108.59,108.87,108.22,109.15,109.31,109.42,109.4,109.22,109.37,109.11,108.92,108.9,109.22,109.35,109.82,109.67,109.48,110.55,110.11,109.83,109.44,109.61,109.8,110.0,109.76,109.79,109.67,109.56,110.05,110.05,108.92,109.24,109.16,108.74,109.46,109.4,109.38,109.76,109.23,109.22,109.44,109.28,109.43,109.64,109.44,109.51,108.8,108.83,107.97,108.0,108.03,108.2,107.62,108.28,108.51,108.8,109.47,109.61,109.72,109.9,109.67,109.88,109.64,110.17,110.22,110.47,110.28,110.09,109.22,109.14,109.26,109.38,109.44,109.59,110.38,110.33,110.42,110.56,110.69,110.35,110.85,110.22,111.14,111.11,111.16]},{"panel":0,"label":"random forest (0.820)","color":"var(--chart-grey, #a3a19c)","x":[0.0,1.0],"y":[0.820362,0.820362],"sx":[74.04,75.6],"sy":[69.64,69.64]}]}
2026-10-15T18:29:04.452167
image/svg+xml
Matplotlib v3.11.2, https://matplotlib.org/
0
50
100
150
200
250
300
Number of trees in the model
0.50
0.55
0.60
0.65
0.70
0.75
0.80
0.85
0.90
Test AUC, 2022–2023 (0.5 = coin flip, 1 = perfect)
Test score as trees are added (dot = round chosen on validation)
AdaBoost, stumps
gradient boosting, depth-3 trees, rate 0.1
gradient boosting, depth-3 trees, rate 1.0
random forest (0.820)
For this chart the models trained on 2019 and 2020 (2,425 rows) and kept 2021 (1,260 rows)
aside as a validation set, after the fitting months, never mixed in. The number of trees to use
is chosen on that validation set, never on the test set, and the dot on each line marks the
round it picked. Test AUC on 2022 to 2023:
Model 10 trees 50 trees 300 trees Chosen on validation Test AUC there AdaBoost, stumps 0.756 0.792 0.789 78 0.795 Gradient boosting, depth-3 trees, rate 0.1 0.817 0.814 0.786 42 0.817 Gradient boosting, depth-3 trees, rate 1.0 0.770 0.719 0.739 5 0.792 Random forest (last post) 0.820
Two lessons from the chart above:
Too high a learning rate overfits fast. At rate 1.0 each tree over-corrects. The score
peaks after five trees, then falls to 0.72 by fifty as the model fits noise; the validation
set stops it at 5.
Boosting can overfit by adding trees , unlike a random forest. Even at rate 0.1 the score
drifts down from 0.817 to 0.786 over 300 trees. In practice you use early stopping : watch a
validation score and stop adding trees when it stops improving, which is what the dots show.
On this data the random forest (0.820) edged out the best boosting run (0.817). Common experience
on tabular data is the reverse, but it isn’t a law: with few features, overlapping rows and
noisy labels, forests often win because they’re harder to overfit, and that is exactly this
problem.
The code
from sklearn . ensemble import AdaBoostClassifier , GradientBoostingClassifier
from sklearn . tree import DecisionTreeClassifier
ada = AdaBoostClassifier ( DecisionTreeClassifier ( max_depth = 1 ), # stumps
n_estimators = 300 , learning_rate = 1.0 )
ada . fit ( X_train , y_train )
ada . estimator_errors_ [: 3 ], ada . estimator_weights_ [: 3 ] # epsilon and alpha per round (0.1414, 1.8038, ...)
gb = GradientBoostingClassifier ( n_estimators = 300 , learning_rate = 0.1 , max_depth = 3 ,
validation_fraction = 0.1 , n_iter_no_change = 20 ) # early stopping
gb . fit ( X_train , y_train )
gb . n_estimators_ # trees actually used (42 here)
For large datasets, scikit-learn’s HistGradientBoostingClassifier, XGBoost and LightGBM are much
faster versions of the same idea.
Why banks use boosted trees
Stronger libraries. XGBoost and LightGBM add regularisation, histogram-based splits and
built-in handling of missing values.
Monotonic constraints , for example “risk can only go up as hours booked late rises”, which
credit and model-risk teams like because the model can’t contradict common sense.
Explanations. SHAP values explain an individual prediction, feature by feature.
The trade-off: more settings to tune than a random forest, and easier to overfit.
Summary
Idea Formula / rule Remember it as Boosting weak models in sequence, each fixing the last a team where each member covers the gaps AdaBoost vote α = 1 2 ln ( ( 1 − ε ) / ε ) \key{\alpha} = \tfrac{1}{2}\ln\big((1-\risk{\varepsilon}) / \risk{\varepsilon}\big) α = 2 1 ln ( ( 1 − ε ) / ε ) lower error, bigger say AdaBoost update wrong × e α \bad{e^{\key{\alpha}}} e α , right × e − α \good{e^{-\key{\alpha}}} e − α , normalisemistakes end up with half the weight scikit-learn AdaBoost α = ln ( ( 1 − ε ) / ε ) \key{\alpha} = \ln\big((1-\risk{\varepsilon}) / \risk{\varepsilon}\big) α = ln ( ( 1 − ε ) / ε ) (SAMME)twice the textbook value, same ranking Gradient boosting f ^ ← f ^ + λ f ^ b \hat{f} \leftarrow \hat{f} + \key{\lambda} \hat{f}^b f ^ ← f ^ + λ f ^ b , f ^ b \hat{f}^b f ^ b fits the residuals keep fitting what’s left over Main danger too many trees or too high a rate use a small rate and early stopping
That completes the ML basics series : what machine learning is ,
regression versus classification ,
linear regression , decision trees ,
bias and variance , bagging ,
random forests and boosting.
Next
The next series is coming soon. Until then, the finance stats series
covers the probability and risk ideas these models are measured with.
References
James, Witten, Hastie, Tibshirani and Taylor, An Introduction to Statistical Learning, with Applications in Python (Springer, 2023), section 8.2.3: boosting, Algorithm 8.2 (equations 8.10 to 8.12)
Kevin P. Murphy, Probabilistic Machine Learning: An Introduction (MIT Press, 2022), chapter 18: AdaBoost (β and α = 2β) and gradient boosting
Yoav Freund and Robert E. Schapire, “A Decision-Theoretic Generalization of On-Line Learning and an Application to Boosting”, Journal of Computer and System Sciences 55(1), 119–139, 1997
Jerome H. Friedman, “Greedy Function Approximation: A Gradient Boosting Machine”, The Annals of Statistics 29(5), 1189–1232, 2001
scikit-learn: AdaBoost and gradient boosting