What is the difference between a loss function, a cost function, and an objective function?

Quick Overview

Explain how a loss function, a cost function and an objective function differ in machine learning. Tests whether you can distinguish the three terms by scope and role, place regularization correctly, and tell a training objective apart from an evaluation metric.

What is the difference between a loss function, a cost function, and an objective function?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: easy

Interview Round: Other

What is the difference between a loss function, a cost function, and an objective function? ```hint Label the pieces Write down the training objective for L2-regularized linear regression, then mark each term by how many examples it depends on and whether the optimizer minimizes or maximizes it. ``` ### What a Strong Answer Covers - What a loss function measures and at what scope - What a cost function is and how it relates to the loss, including anything added beyond the data term - How the objective function relates to the other two, with an example of an objective that is maximized - How the terms are used in practice, including in common libraries ### Follow-up Questions - Why do classifiers usually train on log loss when the metric you report is accuracy? - Is the regularization term part of the loss or the cost? Does the answer matter when you train on mini-batches? - Give an objective that is not a sum or average of per-example losses. - How does the cost on a mini-batch relate to the cost on the full dataset in stochastic gradient descent?

Overview: Explain how a loss function, a cost function and an objective function differ in machine learning. Tests whether you can distinguish the three terms by scope and role, place regularization correctly, and tell a training objective apart from an evaluation metric.

General logo
General
Nov 25, 2026
easyMachine Learning EngineerOtherMachine Learning
0
0

What is the difference between a loss function, a cost function, and an objective function?

What a Strong Answer Covers Guidance

  • What a loss function measures and at what scope
  • What a cost function is and how it relates to the loss, including anything added beyond the data term
  • How the objective function relates to the other two, with an example of an objective that is maximized
  • How the terms are used in practice, including in common libraries

Follow-up Questions Guidance

  • Why do classifiers usually train on log loss when the metric you report is accuracy?
  • Is the regularization term part of the loss or the cost? Does the answer matter when you train on mini-batches?
  • Give an objective that is not a sum or average of per-example losses.
  • How does the cost on a mini-batch relate to the cost on the full dataset in stochastic gradient descent?