All problems
Guardrail Degradation
Problem
Compute guardrail metric degradation in percent, counting only harm: max(0, (control - treatment) / control) * 100.
Return 0.0 when control is 0 or the treatment matches or beats the control.
Hint
Guardrails only care about regressions, so improvements clamp to 0.
Test cases
case 1
in: [0.05,0.06]
expected: 0
case 2
in: [0.06,0.05]
expected: 16.66666666666666
case 3
in: [0.2,0.15]
expected: 25.000000000000007
case 4
in: [0,0.1]
expected: 0
Starter codePython
def guardrail_degradation(control, treatment):
# Your code here
pass4 test cases · run your code against them in the editor