Mean Squared Error, or MSE, is a metric for evaluating the performance of regression models. It measures how far off your model’s predictions are from the actual values, but with a twist: it squares the errors first.
Why? Because squaring punishes larger errors more severely, which helps surface models that are not just slightly wrong but way off the mark.
How to calculate mean squared error?
- Take the difference between each predicted value and the actual value (aka the residual).
- Square each of those residuals.
- Average them.
Mathematically:
Where:
- yi is the actual value
- ŷi is the predicted value
- n is the number of data points
Why use MSE?
- Smooth optimization: The squared term makes MSE continuous and differentiable, perfect for algorithms like gradient descent.
- Intuitive penalization: Big mistakes cost more. A 10-point error isn’t just worse than a 5-point error, it’s four times worse.
- Foundational: MSE is baked into the loss functions of many models, including linear regression and neural nets.
Downsides of MSE
- Outlier sensitive: MSE can be overly influenced by large errors, which might not be ideal in noisy datasets.
- Harder to interpret: Because the errors are squared, the units of MSE are the square of your original units (e.g., square dollars or square meters).
How to use MSE with FiftyOne
FiftyOne stores numeric labels as fo.Regression objects. Once your samples contain both a ground-truth regression field (e.g. "ground_truth") and a predictions field (e.g. "predictions"), you can call evaluate_regressions() to compute an entire suite of regression metrics—including mean-squared error—without leaving the FiftyOne ecosystem. The call returns a RegressionResults object; its metrics() method yields a dictionary of standard scores ("mse", "rmse", "mae", "r2", etc.), and the framework automatically writes per-sample errors back to the dataset if you pass an eval_key, so you can inspect the worst offenders in the FiftyOne App.
The below example script clones FiftyOne’s “quickstart” dataset, adds some mock ground-truth and predicted counts, then computes and prints their mean-squared error.
Mean Squared Error is a classic way to quantify how accurate your regression model is. It squares errors to highlight big misses, works well with gradient descent, and plays a central role in model training. Just watch out for outliers.