AI301 — Original on-site preparation
Independent written study. All essential explanations and optional model reasoning for this chapter are on this page. References are optional further study. No degree, professional approval or observed competence is conferred.
Learn a split, then distinguish averaging from sequential correction
A fitted tree chooses predicates from training data. A hand-written rule such as hours>8 demonstrates routing, but leaves the fitting mechanism unexplained. For binary classification, let p be the fraction of positive training labels reaching a node. Its Gini impurity is 1−p²−(1−p)²=2p(1−p). It is zero for a pure node and one half for an evenly mixed node. This is a description of the labels reaching that node, not a held-out error rate.
Consider six fictional jobs with ordered feature values [1,2,3,4,5,6] and labels [0,0,1,1,1,0]. The root has three positives, so impurity is .5. For a threshold 2.5, send x≤2.5 left. The two left labels are pure zeros, while the four right labels have positive fraction 3/4 and impurity 3/8. Weight by node sizes: (2/6)×0+(4/6)×(3/8)=1/4. The impurity decrease is 1/4. Threshold 3.5 instead produces two groups of three, each with impurity 4/9, so its weighted impurity is 4/9 and decrease 1/18. The first split is preferable under this criterion among these two candidates.
To find the best split on this feature, examine midpoints between each adjacent distinct training value. Thresholds 1.5,2.5,3.5,4.5,5.5 have weighted impurities .4,.25,4/9,.5,.4 respectively;2.5 wins here. This is a greedy local choice. Recursing can fit increasingly specific training patterns without finding a globally best bounded tree or establishing generalization. Minimum leaf size, depth limits and pruning restrict the candidates or retained structure. Tune these choices in development data. A leaf's training class fraction is a fitted probability estimate, not automatic calibration.
Resample and average
Bootstrap sampling draws training row indices with replacement. A six-row draw [0,0,2,3,3,5] includes repeated rows and excludes 1 and 4. Fit one tree on that draw and other trees on other draws. Bagging aggregates their predictions; a random forest also considers randomized feature subsets when selecting splits. For three fitted probability outputs [.2,.7,.6], their average is .5. Under the declared positive-at-.5 convention the forest predicts positive. Averaging probabilities differs from taking a majority of thresholded labels: [.49,.49,.99] averages above .5, while two of its three individually thresholded predictions are negative.
For M estimators with equal error variance σ² and equal pairwise correlationρ, the average's variance is σ²[ρ+(1−ρ)/M]. Expanding the variance of a sum proves the expression. Atρ=0 it falls toσ²/M; atρ=1 it staysσ². Diversity therefore matters, and extra copies of one identical tree do not create independent evidence. Real trees need not satisfy the equal-variance/correlation assumptions. Out-of-bag predictions use only trees whose bootstrap sample omitted that row; they do not automatically enforce customer separation or a future-time evaluation boundary.
Fit the remaining loss direction
Boosting builds an additive function sequentially. For half-squared loss, the negative derivative with respect to a prediction is the residual y−F(x). Fit a small regression tree to those residuals and update Fnew=F+ηh. For targets [1,1,5,5], a constant initial mean is 3, with residuals [−2,−2,2,2]. A stump separating the first pair from the second predicts residuals−2 and 2. Withη=.5, predictions become[2,2,4,4]. Mean squared error falls from 4to 1. Withη=1, this deliberately simple training fixture fits exactly. Neither result establishes held-out improvement. For classification the negative gradient depends on the classification loss; it is not generally the raw class label minus a thresholded prediction.
Optional changed labels and full reasoning
Change the six-job labels to[0,1,1,1,0,0]. Compare thresholds 2.5 and 3.5. At 2.5 the left fraction is 1/2 and the right fraction 1/2, so weighted impurity stays.5. At 3.5 the left fraction is 2/3 and the right 1/3; both impurities are 4/9. The latter wins among these two, though all candidate thresholds must be checked before claiming a global best split for this feature. For the boosting fixture, changeηto 1.5: predictions[0,0,6,6] have MSE 1, whileη=2 gives[−1,−1,7,7]with MSE 4. A direction that decreases loss for a small step does not certify every finite step. Finally, three identical probability predictions.7average to.7; replication changes neither the fitted decision nor the amount of independent evidence.
Optional criteria, one point each: compute weighted child impurities with the stated routing rule; distinguish local training fit from evaluation; trace bootstrap membership and probability aggregation; calculate a residual update and limit its interpretation. Four points require explained calculations and assumptions, not only selected thresholds.
Optional source references
These sources support the explanations; reading them is optional. Original Academy examples are fictional. Historical attributed readings remain preserved.