Why does early stopping on a custom metric differ from using that metric as a boosted model's objective?

Quick Overview

Asks why a gradient-boosted model that uses a custom metric for early stopping differs from one trained with that metric as its objective. It tests whether you know what gradients and Hessians control in boosting, why metrics like AUC or F1 need surrogates, and how to align objective and metric.

Why does early stopping on a custom metric differ from using that metric as a boosted model's objective?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Other

You train a gradient-boosted model and add a custom evaluation metric for early stopping, and the metric improves. Why might this model still behave differently from one that optimizes that metric as its training objective? ```hint Who builds the trees Ask which quantity the library uses to compute split gains and leaf values, and which quantity it only reads after each round. ``` ```hint Try it as an objective What would the gradient of AUC or F1 with respect to a single prediction look like if you nudged that prediction slightly? ``` ### What a Strong Answer Covers - The separate roles of the training objective and the evaluation metric in a boosting library. - Why the model follows the objective's optimization path even when early stopping watches the metric. - How the objective and the metric can weight errors differently. - Why many metrics cannot be used directly as objectives, and what a surrogate has to provide. - Practical consequences of selecting rounds on the metric and of the objective's effect on the outputs. ### Follow-up Questions - How would you write a custom objective for a boosting library, and what must it return? - Your metric is MAPE. Why is it awkward as a boosting objective, and what would you use instead? - Early stopping on the metric picks round 120, but the validation log loss is still falling at round 400. Which model would you ship? - How does a pairwise ranking objective relate to AUC?

Overview: Asks why a gradient-boosted model that uses a custom metric for early stopping differs from one trained with that metric as its objective. It tests whether you know what gradients and Hessians control in boosting, why metrics like AUC or F1 need surrogates, and how to align objective and metric.

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

You train a gradient-boosted model and add a custom evaluation metric for early stopping, and the metric improves. Why might this model still behave differently from one that optimizes that metric as its training objective?

What a Strong Answer Covers Guidance

  • The separate roles of the training objective and the evaluation metric in a boosting library.
  • Why the model follows the objective's optimization path even when early stopping watches the metric.
  • How the objective and the metric can weight errors differently.
  • Why many metrics cannot be used directly as objectives, and what a surrogate has to provide.
  • Practical consequences of selecting rounds on the metric and of the objective's effect on the outputs.

Follow-up Questions Guidance

  • How would you write a custom objective for a boosting library, and what must it return?
  • Your metric is MAPE. Why is it awkward as a boosting objective, and what would you use instead?
  • Early stopping on the metric picks round 120, but the validation log loss is still falling at round 400. Which model would you ship?
  • How does a pairwise ranking objective relate to AUC?