Back to Practice
#0079

MAE and RMSE

EasyML15 min15 XP

Problem

Given y_true and y_pred lists, return a dictionary with mae and rmse.

Why This Matters

Metrics decide what model looks best. MAE is easy to interpret; RMSE punishes large errors harder.

Function Signature

def regression_metrics(y_true, y_pred):

Examples

Example 1
Input[3, 5], [2, 7]
Output{"mae": 1.5, "rmse": 1.5811...}

Errors are 1 and -2.

Constraints

  • Lists are the same non-zero length.
  • Return floats.
  • Do not round unless a caller asks.
CodePython
Visible browser tests run here when available.
Testcases1 visible / 3 hidden categories
Two predictions
Input[3,5], [2,7]
Expectedmae 1.5 and rmse sqrt(2.5)

Absolute errors are 1 and 2.

Hidden Test Categories
perfect predictionsnegative valuesthree or more rows