All problems
Expected Zero One Loss
Problem
The optimal 0/1 classifier predicts the most likely class, so its expected loss is 1 minus the maximum posterior probability.
Given the class posteriors, return the expected zero-one loss.
Hint
The error is the mass outside the predicted class.
Test cases
case 1
in: [[0.7,0.3]]
expected: 0.30000000000000004
case 2
in: [[0.5,0.5]]
expected: 0.5
case 3
in: [[0.1,0.2,0.7]]
expected: 0.30000000000000004
Starter codePython
def expected_zero_one_loss(posteriors):
# Your code here
pass3 test cases · run your code against them in the editor