3.6 MSE and RMSE
[video] /api/lesson-media/videos/9b417aa2-5e9f-4ae3-a9db-2a3b7f03f372-1794878472342-3de2557e0c5d2462.mp4
[markdown] content available only on the platform
Flashcards · 3.6 MSE and RMSE
Mean squared error (MSE) — The average of the squared prediction errors; its unit is the square of the target's unit.
Errors 0.5, -0.5, 0, -1, 1 -> MSE = 2.5 / 5 = 0.5
Root mean squared error (RMSE) — The square root of MSE, which brings the error back to the same unit as the target.
sqrt(0.5) = 0.707 billion VND
Squaring penalises large errors — Squaring makes big errors count disproportionately: an error 10 times larger contributes 100 times more.
0.1^2 = 0.01 but 1^2 = 1.
RMSE vs MAE — RMSE is always at least MAE; a much larger RMSE signals a few very large errors.
MAE 1.4 vs RMSE 2.30 after one 5-billion error.
Outlier sensitivity of RMSE — One large error raises RMSE far more than MAE, so RMSE suits cases where big mistakes are costly.
One bad house: MAE x2.3, RMSE x3.3.
mean_squared_error() — scikit-learn function computing MSE; always pass y_true before y_pred.
mean_squared_error(y_true, y_pred) -> 0.5
root_mean_squared_error() — scikit-learn function (version 1.4 and later) that computes RMSE directly.
root_mean_squared_error(y_true, y_pred) -> 0.7071
squared=False (removed) — An old way to get RMSE from mean_squared_error; newer scikit-learn versions removed it and raise a TypeError.
Use np.sqrt(mean_squared_error(...)) instead.
MSE of the mean baseline — Always predicting the mean gives an MSE equal to the variance of y, a reference for judging MSE.
np.var(y_true) = 2.0, so R-squared = 1 - 0.5 / 2.0 = 0.75
