What is the cost function in Linear Regression?

Updated May 16, 2026

Short answer

It measures the error between predicted and actual values, usually using Mean Squared Error (MSE).

Deep explanation

The cost function quantifies how well the model fits the data. MSE penalizes larger errors more heavily by squaring differences. The goal of training is to minimize this cost function.

Real-world example

Evaluating prediction error in salary estimation models.

Common mistakes

  • Confusing MSE with MAE and not understanding sensitivity to outliers.

Follow-up questions

  • Why square errors instead of absolute values?

More Linear Regression interview questions

View all →