All problems
Cost-Sensitive Decision Threshold
Problem
Compute the cost-sensitive decision threshold for predicting the positive class: cost_fp / (cost_fp + cost_fn). Predict positive when the estimated probability exceeds this break-even point. Return 0.0 when the two costs sum to 0 or less.
Hint
When false negatives are expensive the threshold drops below 0.5 to catch more positives.
Test cases
case 1
in: [1,4]
expected: 0.2
case 2
in: [5,5]
expected: 0.5
case 3
in: [0,3]
expected: 0
case 4
in: [0,0]
expected: 0
case 5
in: [3,1]
expected: 0.75
Starter codePython
def cost_sensitive_threshold(cost_fp, cost_fn):
# Your code here
pass5 test cases · run your code against them in the editor