All problems
LARS Trust Ratio
Problem
Compute the LARS trust ratio for a weight vector and an update.
Return ||w|| / (||update|| + eps). This scales the update so its norm matches the weight norm.
Hint
eps keeps the ratio finite when the update is the zero vector.
Test cases
case 1
in: [[3,4],[1,0],1e-8]
expected: 4.999999950000001
case 2
in: [[1,1],[2,2],0]
expected: 0.5
case 3
in: [[0,0],[1,1],1e-8]
expected: 0
Starter codePython
def lars_trust_ratio(w, update, eps):
# Your code here
pass3 test cases · run your code against them in the editor