Bagging trains independent trees. Boosting trains the next tree specifically to correct the current ensemble's remaining errors. For squared error, that correction target has a simple exact form: the signed residual.
Implement negative_gradient and fit_tree_to_negative_gradient, using the existing regression-tree builder to fit the current residuals rather than original targets.
targets and predictions have matching shapes.targets - predictions, not the opposite sign.build_regression_tree(input, residuals, max_depth).Open one at a time. Each gives away a little more than the last.
For a squared-error underprediction, the correction must be positive.
Compute the residual through negative_gradient, then pass it as the tree's target array.
No results yet
Run your code to check it against the examples, or submit to run every test.