A courier company predicts how many minutes a delivery will take from its distance in km. They use gradient boosting: a chain of tiny trees, where every new tree is trained on whatever error the chain still makes.
The recipe runs like this.
thresholds, in order:
t?, where t is this round's threshold. Each of its two leaves outputs the average residual of the training records that land in it. A leaf that receives no training records outputs 0.learning_rate × the tree's output for that record.learning_rate × each tree's output for that distance.Task: write boost_predict(xs, ys, thresholds, learning_rate, queries) and return the final model's predictions for every distance in queries, each rounded to 4 decimal places.
xs[i] and ys[i] are training record i's distance and true delivery time.learning_rate is between 0 and 1. It shrinks every correction, so each tree only fixes part of what is left.