Calculate mean squared error between predicted and actual values.
Mean Squared Error (MSE) is the average of squared prediction errors: MSE = (1/n) × Σ(y_i − ŷ_i)². Squaring the errors penalizes larger deviations disproportionately more than smaller ones, making MSE especially sensitive to outliers. MSE is also mathematically convenient because it's differentiable everywhere, which is why it's the default loss function for training many regression models via gradient descent. Its units are the square of the target variable's units, which is why RMSE (its square root) is often reported instead for easier interpretation.
MSE = (1/n) * sum((y_i - y_hat_i)^2)
Squaring makes the loss function smooth and differentiable everywhere (unlike absolute value, which has a kink at zero), which is convenient for gradient-based optimization, and it heavily penalizes large errors, which can be desirable when big mistakes are especially costly.
MSE is in squared units of the target variable, so if you're predicting dollars, MSE is in 'dollars squared', which has no intuitive real-world meaning — RMSE converts this back to the original units by taking the square root.
Yes — since every term is a squared value, MSE is always greater than or equal to zero, with 0 occurring only when every prediction exactly matches its actual value.