A payments company's fraud team reports F1 and ROC-AUC, yet trains its classifier with gradient descent on log loss. A product manager asks: "Why not minimise 1 − F1, or maximise AUC, directly?" Which answer is correct?
Show the answer and explanation
Correct answer: B, F1 and AUC are computed from thresholded predictions or pairwise orderings, so they change in jumps as the weights move and have zero gradient almost everywhere; log loss is a smooth surrogate.
Explanation Optimization
Gradient descent needs a loss whose gradient says which way to move the weights. Accuracy, precision, recall and F1 depend on the predicted labels 1[score ≥ t], and empirical AUC depends on the ordering of score pairs (the share of positive–negative pairs ranked correctly). A tiny weight change usually flips no label and no pair, so the metric does not change at all; occasionally one flips and the metric jumps. As functions of the weights these metrics are piecewise constant: the gradient is zero almost everywhere and undefined at the jumps, so gradient descent gets no signal, even with full batches.
So we train on smooth surrogate losses that track the metric:
| Target metric | Common surrogate |
|---|---|
| accuracy / F1 | log loss (cross-entropy), hinge loss |
| ROC-AUC, ranking | pairwise logistic or hinge loss on score differences (RankNet-style) |
| F1 at an operating point | log loss, then tune the threshold on validation data |
Log loss is also a proper scoring rule, so it yields probabilities that can be thresholded for any business cost.
Why the distractors fail: non-convexity is not the obstacle, since deep networks are trained on non-convex losses every day (log loss is convex in the logits, not in a network's weights, so it guarantees no global minimum either); the obstacle is the missing gradient. Full-batch computation does not make F1 smooth. And empirical AUC is still a count of correctly ordered pairs, so integrating over thresholds does not smooth it.
Interview tip: say "train on a differentiable surrogate, select models and thresholds on the business metric"; smoothed F1 or AUC losses exist, but they are rarely needed in practice.