Skip to content
DeepForgeby svx
All problems
HardML Fundamentalsml-236

Revenue Optimization Threshold

Problem

Choose the probability threshold that maximizes expected profit. For each unique probability t, act on samples with p >= t and earn p * value - cost per action.

Return [best_threshold, best_profit]; ties keep the smallest threshold and empty input returns [0.0, 0.0].

Hint

Act whenever the expected value p * value exceeds the action cost.

Test cases

case 1
in: [[0.9,0.6,0.3],[10,10,10],2]
expected: [0.3,12]
case 2
in: [[0.2,0.25],[100,100],10]
expected: [0.2,25]
case 3
in: [[0.1],[100],5]
expected: [0.1,5]
case 4
in: [[0.01],[1],10]
expected: [0.01,-9.99]
Starter codePython
def revenue_optimization(probs, values, cost):
    # Returns [best_threshold, best_profit]
    # Your code here
    pass

4 test cases · run your code against them in the editor