Skip to content
DeepForgeby svx
All problems
MediumDeep Learningdl-309

Cascade Inference

Problem

Model a two-model cascade: a small model answers everything and a fraction (1 - confidence_gate) escalates to the large model. Accuracy = gate * small_acc + (1 - gate) * large_acc and cost = small_cost + (1 - gate) * large_cost.

The signature is cascade_inference(small_accuracy, small_cost, large_accuracy, large_cost, confidence_gate). Return [accuracy, cost].

Hint

Cascades buy most of the large model's accuracy at a fraction of its cost.

Test cases

case 1
in: [0.8,1,0.95,10,0.7]
expected: [0.845,4]
case 2
in: [0.9,2,0.99,20,0]
expected: [0.99,22]
case 3
in: [1,1,1,1,1]
expected: [1,1]
case 4
in: [0.5,1,0.9,5,1]
expected: [0.5,1]
Starter codePython
def cascade_inference(small_accuracy, small_cost, large_accuracy, large_cost, confidence_gate):
    # Your code here
    pass

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