All problems
Trust Region Gain Ratio
Problem
Evaluate the gain ratio of a trust-region step.
If predicted <= 0 use ratio 0.0, otherwise ratio = actual / predicted. Return [ratio, accepted, shrink] where accepted is ratio > eta and shrink is ratio < 0.25.
Hint
A poor ratio means the model predicted more reduction than reality delivered.
Test cases
case 1
in: [0.1,1,0.1]
expected: [0.1,false,true]
case 2
in: [0.9,1,0.1]
expected: [0.9,true,false]
case 3
in: [0.2,0,0.1]
expected: [0,false,true]
case 4
in: [0.05,1,0.25]
expected: [0.05,false,true]
Starter codePython
def trust_region_ratio(actual, predicted, eta):
# Returns [ratio, accepted, shrink]
# Your code here
pass4 test cases · run your code against them in the editor