All problems
One-vs-Rest Prediction
Problem
One-vs-rest prediction: for each row of per-class classifier scores, return the index of the largest score.
Ties go to the smallest index. Empty input returns [].
Hint
Use a strict greater-than comparison so ties keep the earlier class.
Test cases
case 1
in: [[[0.2,0.7,0.1],[0.9,0.05,0.05]]]
expected: [1,0]
case 2
in: [[[1,1,1]]]
expected: [0]
case 3
in: [[[-1,-2]]]
expected: [0]
case 4
in: [[[-3,-1,-2]]]
expected: [1]
Starter codePython
def ovr_predict(scores):
# Your code here
pass4 test cases · run your code against them in the editor