Mean Squared Error Calculator

Mean Squared Error Calculator

Growing AI Skill PRO

Enter Calculation

Formula

MSE=1n∑i=1n(yi−y^i)2\text{MSE} = \frac{1}{n}\sum_{i=1}^{n}\left({y_i} - {{\hat{y}_i}}\right)^2
Usage stats

Advertisement

Results

Mean Squared Error
0.375
MSE · Paired values: 4
Root Mean Squared Error (RMSE) 0.6124
Sum of Squared Errors (SSE) 1.5
Number of pairs (n) 4

Report an error on this page

What is Mean Squared Error?

Mean Squared Error (MSE) is one of the most widely used metrics for measuring how close a set of predictions is to the actual observed values. It averages the squared differences between each predicted value (\(\hat{y}\)) and its corresponding actual value (\(y\)). Because the errors are squared, larger mistakes are penalized more heavily than small ones, and the result is always non-negative — a perfect model scores exactly 0.

Scatter plot with a regression line and vertical residual segments between data points and the line
MSE measures the average of the squared residuals (vertical gaps) between actual points and the predicted line.

How to use this calculator

Enter your actual values and predicted values as two comma-separated lists. The lists should be the same length, with each predicted value lining up with the actual value in the same position. The calculator pairs them in order, computes the squared error for each pair, and returns the MSE along with the related RMSE (root mean squared error) and SSE (sum of squared errors). If the two lists differ in length, only the overlapping pairs are used.

The formula explained

The MSE formula is $$\text{MSE} = \frac{1}{n}\sum_{i=1}^{n}\left(y_i - \hat{y}_i\right)^2$$ For each data point you subtract the prediction from the actual value, square that difference, add all the squared differences together (this is the SSE), and finally divide by the number of points \(n\). Taking the square root of the MSE gives the RMSE, which is convenient because it shares the same units as the original data.

Advertisement
Diagram showing a residual being squared into a square area
Each error is squared before averaging, so larger deviations are penalized more heavily.

Worked example

Suppose the actual values are 3, −0.5, 2, 7 and the predictions are 2.5, 0.0, 2, 8. The errors are 0.5, −0.5, 0, −1. Squaring gives 0.25, 0.25, 0, 1, which sum to 1.5 (the SSE). Dividing by \(n = 4\) gives an MSE of 0.375, and the RMSE is \(\sqrt{0.375} \approx 0.6124\).

Interpreting Your MSE and RMSE

Mean Squared Error averages the squared differences between actual and predicted values. MSE = 0 means a perfect fit: every prediction equals its actual value. Any larger value means some error exists, but whether it is "large" depends on context.

  • Scale and units: MSE is in the squared units of the target. If you predict prices in dollars, MSE is in dollars². Rescaling the data (for example dollars to thousands of dollars) changes MSE by the square of the scaling factor, so there is no universal "good" MSE.
  • RMSE is in original units: \(\text{RMSE} = \sqrt{\text{MSE}}\), so it can be read directly as a typical error size in the same units as your data (weighted toward larger errors).
  • Baseline comparison: A model that always predicts the mean of the target has an MSE equal to the (population) variance of the target. For actual values 10, 12, 14, 16, 18 the mean is 14, and predicting 14 every time gives MSE = (16 + 4 + 0 + 4 + 16) / 5 = 8. A useful model should have an MSE clearly below this baseline.
  • RMSE vs. spread: Compare RMSE with the standard deviation or the range of the data. An RMSE much smaller than the standard deviation suggests the model explains much of the variation; an RMSE close to or above it suggests little improvement over guessing the mean.
  • Outlier sensitivity: Because errors are squared, a single large miss can dominate MSE and RMSE. If a few extreme points are not representative, also check MAE.
  • Valid comparisons: Only compare MSE values computed on the same dataset and the same scale. An MSE from a different dataset or different units says little about relative quality.
  • Train vs. test: Compute MSE on both training and test data. A very low training MSE with a much higher test MSE is a classic sign of overfitting.

MSE vs RMSE Across Different Error Scenarios

All scenarios use the same actual values: 10, 12, 14, 16, 18 (n = 5). Errors are predicted minus actual. Only the predictions change.

Scenario Predicted values Errors SSE MSE RMSE MAE
Perfect prediction 10, 12, 14, 16, 18 0, 0, 0, 0, 0 0 0 0 0
Small uniform errors 11, 11, 15, 15, 19 +1, −1, +1, −1, +1 5 1 1 1
One large outlier error 10, 12, 14, 16, 23 0, 0, 0, 0, +5 25 5 ≈ 2.236 1
Constant bias (+2) 12, 14, 16, 18, 20 +2, +2, +2, +2, +2 20 4 2 2

Worked check for the outlier row: $$\text{SSE} = 0^2 + 0^2 + 0^2 + 0^2 + 5^2 = 25,\quad \text{MSE} = \frac{25}{5} = 5,\quad \text{RMSE} = \sqrt{5} \approx 2.236,\quad \text{MAE} = \frac{5}{5} = 1$$

Takeaway: The small-uniform-error and outlier scenarios have the same MAE (1), yet the outlier raises MSE from 1 to 5 because the single error of 5 is squared to 25. The constant-bias scenario shows that a consistent offset of 2 gives RMSE and MAE both equal to 2, since all errors have the same size.

Advertisement

Key Terms and Related Metrics

  • n: the number of data points (pairs of actual and predicted values). MSE divides by n.
  • Residual: the difference between an actual value and its prediction for one point, \(e_i = y_i - \hat{y}_i\) (the sign convention does not matter for MSE because errors are squared).
  • SSE (sum of squared errors): \(\sum e_i^2\). It is related to MSE by \(\text{SSE} = n \times \text{MSE}\).
  • MSE (mean squared error): \(\text{SSE}/n\), the average squared residual, in squared units of the target.
  • RMSE (root mean squared error): \(\sqrt{\text{MSE}}\), in the same units as the target.
  • MAE (mean absolute error): \(\frac{1}{n}\sum |e_i|\). It weights all errors linearly, so it is less sensitive to outliers than MSE. RMSE is always greater than or equal to MAE.
  • R² (coefficient of determination): \(R^2 = 1 - \text{SSE}/\text{SST}\), where SST is the total sum of squares around the mean of the actual values. Equivalently, \(R^2 = 1 - \text{MSE}/\text{Var}(y)\), so it compares your MSE with the mean-prediction baseline. An R² of 1 matches MSE = 0.
  • Outlier: a data point or error far from the typical pattern. Squaring makes outliers weigh heavily in MSE and RMSE.
  • Overfitting: when a model fits training data very closely (low training MSE) but performs worse on new data (higher test MSE).

FAQ

What is a good MSE value? There is no universal threshold — MSE depends on the scale of your data. Lower is always better, and 0 means a perfect fit. Compare it against alternative models or against the variance of the target.

What is the difference between MSE and RMSE? RMSE is just the square root of MSE. RMSE is often preferred for reporting because it is in the same units as the data and is easier to interpret.

Why square the errors instead of using absolute values? Squaring makes the function smooth and differentiable (useful for optimization) and penalizes large errors more strongly. The alternative, Mean Absolute Error (MAE), treats all errors linearly.

Last updated:

Most popular in Math and Statistics

View all Math and Statistics calculators