All problems
Cost-Weighted Cutoff
Problem
Return the probability cutoff c_fp / (c_fp + c_fn) that minimizes expected cost when a false positive costs cost_fp and a false negative costs cost_fn. Return 0.0 when both costs are zero.
Hint
Predict positive when the expected cost of doing so is lower.
Test cases
case 1
in: [1,1]
expected: 0.5
case 2
in: [4,1]
expected: 0.8
case 3
in: [1,4]
expected: 0.2
case 4
in: [0,0]
expected: 0
case 5
in: [2,8]
expected: 0.2
Starter codePython
def cost_weighted_cutoff(cost_fp, cost_fn):
# Your code here
pass5 test cases · run your code against them in the editor