Back to questions
JuniorTheoryCommon
What does this program print?
import numpy as np
from sklearn.metrics import mean_absolute_error, mean_squared_error
y_true = [1, 2, 3, 4]
y_pred = [1, 2, 3, 8]
mae = mean_absolute_error(y_true, y_pred)
rmse = np.sqrt(mean_squared_error(y_true, y_pred))
print(mae, rmse)1.0 2.0
- Expecting
1.0 4.0:mean_squared_errorreturns MSE, in squared units; the code takes its square root, so RMSE issqrt(4.0) = 2.0. - Expecting MAE and RMSE to match: squaring weights the single error of 4 heavily, so RMSE is twice MAE here; they are equal only when all errors have the same size.
- If rare large errors are costly, would you report mean absolute error (MAE) or root mean squared error (RMSE), and why?
- How would both values change if the one error of 4 were split into four errors of 1?