Boosting keeps a running weight on every training record. After each weak learner (say, a one-split tree) makes its predictions, the weights are updated so the next learner leans toward the records still being missed. The classic recipe for one round, known as AdaBoost, has three steps.
1. Weighted error. Add up the weights of the records the learner got wrong and divide by the total weight:
2. The learner's say. Its vote in the final ensemble gets the weight
using the natural logarithm.
3. Reweight. Multiply every wrong record's weight by and every correct record's weight by . Then divide each new weight by their sum, so the updated weights add up to exactly 1.
Task: write boost_round(labels, predictions, weights) and return the tuple (alpha, new_weights), with alpha and every entry of new_weights rounded to 4 decimal places.
labels[i] is record i's true class and predictions[i] is the learner's guess. Classes can be numbers or strings. A record is wrong whenever the two differ.weights are the weights going into this round. They come from earlier rounds, so they are rarely equal, and they do not always sum to 1.Red points are the ones this tree got wrong. They grow larger, so the next tree pays them more attention.
Points that keep getting missed grow larger with every round. The next tree is trained to care about them more than the rest.
Once your code passes every test, a reference solution shows up here so you can compare it with yours.