Perform the AdaBoost sample-weight update for one boosting round. Labels y and the weak learner's predictions h are in {−1,+1}, weights are the current sample weights and error is the weighted error of the learner. Increase the weight of misclassified samples, decrease the others, and renormalise.
Implement solve(y, h, weights, error).
Returns. Return a new NumPy array of weights that sums to 1. The weights argument is not modified. The error is clamped below at 10−15 so a perfect learner does not divide by zero.
Example 1
Input:
solve([1, 1, -1, -1], [1, -1, -1, -1], [0.25, 0.25, 0.25, 0.25], 0.25)
Output:
[0.166667, 0.5, 0.166667, 0.166667]
Example 2
Input:
solve([1, -1], [1, -1], [0.5, 0.5], 0.5)
Output:
[0.5, 0.5]
No results yet
Run your code to check it against the examples, or submit to run every test.