loss_function_rmse


Loss function: Root Mean Square Error.

rmse = loss_function_rmse(y_true, y_pred)

Input variables

Name Description Type
y_true True values List
y_pred Predicted values List

Output variables

Name Description Type
rmse Root Mean Square Error Float

Problem

\[f(\mathbf{y}_{\text{true}}, \mathbf{y}_{\text{pred}}) = \sqrt{\frac{1}{n} \cdot \sum_{i=1}^{n} (y_{\text{true},i} - y_{\text{pred},i})^2}\]

(1)

\(n\) is the number of samples.

Example 1

Considering the true values \(\mathbf{y}_{\text{true}} = [1.0, 2.0, 3.0, 4.0, 5.0]\) and predicted values \(\mathbf{y}_{\text{pred}} = [1.2, 2.3, 2.9, 4.2, 5.3]\), what is the resulting Root Mean Square Error (RMSE)?

# Data
y_true_example = [1.0, 2.0, 3.0, 4.0, 5.0]
y_pred_example = [1.2, 2.3, 2.9, 4.2, 5.3]

# Call function
rmse_value = loss_function_rmse(y_true_example, y_pred_example)

# Print the result
print("Root Mean Square Error (RMSE): {:.4f}".format(rmse_value))
Root Mean Square Error (RMSE): 0.2324