What does the mean squared error cost J(w) = (1/n) Σ (yᵢ − ŷᵢ)² measure for a linear regression model?
Show the answer and explanation
Correct answer: C, The average squared difference between the predicted and the actual target values over the examples.
Explanation Linear Models
The mean squared error (MSE) cost averages the squared residuals (yᵢ − ŷᵢ)² over the n training examples. Fitting a linear regression by least squares means choosing the weights w that make this cost as small as possible. For linear regression it is a convex quadratic function of w, so it has no spurious local minima.
Worked example: residuals 1, −1, 2, −2 give MSE = (1 + 1 + 4 + 4) / 4 = 2.5.
Why the other descriptions are wrong:
- The average absolute difference is the mean absolute error (MAE), a different cost.
- The share of explained variance is R², which is derived from the squared errors but is not the cost itself.
- The spread of each feature around its mean is the feature variance; it involves no predictions at all.
Interview tip: mention that some courses write the cost as 1/(2n) Σ (yᵢ − ŷᵢ)²; the extra ½ only simplifies the gradient and does not change the minimizer.