All problems
Bayes Risk Minimum Expected Loss
Problem
Given class posteriors and a 2x2 loss matrix (rows are actions, columns are true classes), the Bayes risk is the minimum over actions of sum_j posterior_j loss[a][j].
Given the posteriors and the loss matrix, return the Bayes risk.
Hint
Evaluate every action and take the smallest expected loss.
Test cases
case 1
in: [[0.7,0.3],[[0,1],[1,0]]]
expected: 0.3
case 2
in: [[0.7,0.3],[[0,5],[1,0]]]
expected: 0.7
case 3
in: [[0.5,0.5],[[2,2],[2,2]]]
expected: 2
Starter codePython
def bayes_risk_minimum_expected_loss(posteriors, loss_matrix):
# Your code here
pass3 test cases · run your code against them in the editor