Linear regression most often uses mean-square error (MSE) to calculate the error of the model. MSE is calculated by:

- Measuring the distance of the observed y-values from the predicted y-values at each value of x;
- Squaring each of these distances;
- Calculate the mean of each of the squared distances.

Linear regression fits a line to the data by finding the regression coefficient that results in the smallest MSE.