Which Model Wins?

Machine Learning in CodeMedium+10 XP+10

Which Model Wins?

Two models predicted the same delivery times. Model A's predictions are guess_a and model B's are guess_b. The true times are truth. Which one is better depends on how you measure.

Write better_model(truth, guess_a, guess_b, metric). metric is one of:

  • "mae": lower mean absolute error wins.
  • "rmse": lower root mean squared error wins.
  • "r2": higher R² wins.

Return "A" or "B". Use the sklearn.metrics functions. The two models never tie on the metric asked for in the tests.

Examples

truth = [10, 12, 14, 16, 18]
guess_a = [12, 14, 16, 18, 20]
guess_b = [10, 12, 14, 16, 25]
metric = 'mae'
returns 'B'
truth = [10, 12, 14, 16, 18]
guess_a = [12, 14, 16, 18, 20]
guess_b = [10, 12, 14, 16, 25]
metric = 'rmse'
returns 'A'

Hints

Solve it to unlock the solution

Once your code passes every test, a reference solution shows up here so you can compare it with yours.

solution.py
CtrlEnterto run