All problems
Mean Squared Logarithmic Error
Problem
Compute the mean squared logarithmic error: mean((log1p(y_i) - log1p(pred_i))^2).
Targets and predictions are assumed non-negative. Empty input returns 0.0.
Hint
Apply log1p to both sides before squaring, so ratios matter more than absolute gaps.
Test cases
case 1
in: [[1,2,3],[1,2,3]]
expected: 0
case 2
in: [[0,0],[1,1]]
expected: 0.4804530139182014
case 3
in: [[1,3],[2,1]]
expected: 0.32242748390568343
case 4
in: [[],[]]
expected: 0
Starter codePython
import math
def mean_squared_log_error(y_true, y_pred):
# Your code here
pass4 test cases · run your code against them in the editor