Skip to content
DeepForgeby svx
All problems

RND Predictor Error

Problem

Compute the relative RND predictor error ||predicted - target|| / (||target|| + epsilon). An all-zero target with a nonzero prediction yields a large finite value thanks to epsilon.

Hint

Dividing by the target norm makes the error scale-free.

Test cases

case 1
in: [[1,1],[1,1]]
expected: 0
case 2
in: [[0,0],[3,4]]
expected: 0.9999999980000001
case 3
in: [[1,2],[2,2]]
expected: 0.35355338934327374
case 4
in: [[2,0],[0,1]]
expected: 2.2360679551391103
Starter codePython
import math
def rnd_predictor_error(predicted, target, epsilon=1e-8):
    # Your code here
    pass

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