Why train on a surrogate loss instead of directly optimizing accuracy or F1?

Quick Overview

Asks why classifiers are trained on surrogate losses such as cross-entropy or hinge loss instead of accuracy or F1 directly. Tests understanding of gradients of piecewise-constant metrics, non-decomposable metrics in mini-batch training, classification calibration, and threshold tuning.

Why train on a surrogate loss instead of directly optimizing accuracy or F1?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Other

Why do we train models on a surrogate loss function rather than directly optimizing evaluation metrics like accuracy or F1 score? Explain what goes wrong if you try to optimize the metric itself with gradient descent, what a good surrogate must provide, and how you keep the trained model aligned with the metric you report. ```hint Look at the gradient Picture accuracy as a function of a single weight while every other weight stays fixed. Sketch what its derivative looks like. ``` ```hint Look at how F1 is computed Ask whether F1 over a dataset can be written as a sum of per-example terms, and what that means for mini-batches. ``` ### What a Strong Answer Covers - What happens to the gradient if you optimize accuracy or F1 directly - Why F1 in particular does not fit mini-batch training - The properties a good surrogate needs, including its relationship to the target metric - How to close the gap between the surrogate and the metric you report - Where the true metric still enters the training workflow ### Follow-up Questions - What does it mean for a surrogate loss to be classification-calibrated? Is squared loss calibrated for classification? - When would you train on a differentiable approximation of F1, and what can go wrong? - How does the F1-optimal decision threshold relate to the classifier's predicted probabilities? - Why does hinge loss stop updating on well-classified examples while cross-entropy does not?

Overview: Asks why classifiers are trained on surrogate losses such as cross-entropy or hinge loss instead of accuracy or F1 directly. Tests understanding of gradients of piecewise-constant metrics, non-decomposable metrics in mini-batch training, classification calibration, and threshold tuning.

PracHub logo
General
Nov 24, 2026
mediumMachine Learning EngineerOtherMachine Learning
0
0

Why do we train models on a surrogate loss function rather than directly optimizing evaluation metrics like accuracy or F1 score? Explain what goes wrong if you try to optimize the metric itself with gradient descent, what a good surrogate must provide, and how you keep the trained model aligned with the metric you report.

What a Strong Answer Covers Guidance

  • What happens to the gradient if you optimize accuracy or F1 directly
  • Why F1 in particular does not fit mini-batch training
  • The properties a good surrogate needs, including its relationship to the target metric
  • How to close the gap between the surrogate and the metric you report
  • Where the true metric still enters the training workflow

Follow-up Questions Guidance

  • What does it mean for a surrogate loss to be classification-calibrated? Is squared loss calibrated for classification?
  • When would you train on a differentiable approximation of F1, and what can go wrong?
  • How does the F1-optimal decision threshold relate to the classifier's predicted probabilities?
  • Why does hinge loss stop updating on well-classified examples while cross-entropy does not?