All problems
Augmentation Policy Random Choice
Problem
Choose an augmentation index with a seeded weighted random draw.
Seed the random module, scale random.random() by the total weight and return the first index whose cumulative weight exceeds the draw. Return -1 when the total weight is not positive.
Test cases
case 1
in: [[1,2,3,4],0]
expected: 3
case 2
in: [[1,2,3,4],1]
expected: 1
case 3
in: [[1,2,3,4],42]
expected: 3
case 4
in: [[1,0,0],7]
expected: 0
Starter codePython
def random_augmentation(weights, seed):
# Your code here
pass4 test cases · run your code against them in the editor