What is a cost function in Gradient Descent?

Updated May 16, 2026

Short answer

A cost function measures how wrong a model’s predictions are.

Deep explanation

Gradient Descent minimizes the cost function, which quantifies error between predicted and actual values. Common examples include Mean Squared Error and Cross-Entropy Loss.

Real-world example

Reducing prediction error in house price estimation models.

Common mistakes

  • Confusing cost function with accuracy metric.

Follow-up questions

  • What is difference between loss and cost?
  • Why square error is used?

More Gradient Descent interview questions

View all →