AdaBoost's Sample Reweighting
Ardwick Mutual is training a fraud detector by boosting: not one large model, but a sequence of small ones, each built to concentrate on the claims its predecessors got wrong. The concentrating is done with weights. Every training claim carries one, and the weights are what the next learner in the sequence pays attention to. A learner has just finished and earned a say of its own, a single number called alpha. Before the next learner starts, the weights have to be revised.
Task: Print the revised weight of every training claim.
Input
Four lines. The first holds n, the number of training claims. The second holds their n current weights, separated by single spaces. The third holds n flags in the same claim order: 1 where the learner got that claim wrong, 0 where it got it right. The fourth holds alpha.
Output
n lines, one per claim, in the order the claims arrived, each holding only that claim's revised weight rounded to 4 decimal places. A claim the learner got wrong has its weight multiplied by e raised to alpha; a claim it got right is divided by that same factor. Every revised weight is then rescaled so the n of them add up to 1.
Example:
Input:
2
0.5 0.5
1 0
0.6931471805599453
Output:
0.8000
0.2000
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in