Skip to content
DeepForgeby svx
All problems
EasyML Fundamentalsml-019

Root Mean Squared Error for Regression

Problem

Compute the root mean squared error: RMSE = sqrt((1/n) * sum((y_true_i - y_pred_i)^2)).

Empty input returns 0.0.

Hint

Take the square root of the MSE.

Test cases

case 1
in: [[1,2,3],[1,2,3]]
expected: 0
case 2
in: [[0,0],[3,4]]
expected: 3.5355339059327378
case 3
in: [[2,4,6],[1,2,3]]
expected: 2.160246899469287
case 4
in: [[],[]]
expected: 0
Starter codePython
import math
def root_mean_squared_error(y_true, y_pred):
    # Your code here
    pass

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