CrackML by @ml.with.umang
Interview questions / ML Fundamentals
ML Fundamentals interview question

Choosing a Loss Function

How do you choose a loss function for a new ML problem?

mediumconceptEvidence 34/1001 source reportAmazon

The 60-second answer

Start from the target distribution and business cost: regression vs classification vs ranking, asymmetric errors, label noise, and class imbalance. Use likelihood-aligned defaults such as MSE for Gaussian-style regression or cross-entropy for categorical outcomes, then adapt when assumptions do not match.

Build the answer in this order

1
Give the core idea

Start from the target distribution and business cost: regression vs classification vs ranking, asymmetric errors, label noise, and class imbalance.

2
Explain how it works

Use likelihood-aligned defaults such as MSE for Gaussian-style regression or cross-entropy for categorical outcomes, then adapt when assumptions do not match.

3
Compare alternatives

For ranking/metric mismatch, use pairwise/listwise or differentiable surrogate losses and validate against the actual product metric.

4
State failure modes + validation

Check optimization behavior, calibration, robustness to outliers/noise, and whether sample weighting changes the implied objective.

A useful interview mental model

This is the shape of a strong answer—not a script to memorize.

01Definition
02Mechanism
03Trade-offs
04Failure modes
05When to use

Senior-level signal

  • Senior answers explicitly discuss surrogate-loss mismatch and why directly optimizing a business metric may be impossible or unstable.
  • Include label-generation bias and delayed outcomes as part of the objective design.

What the interviewer is really testing

Mechanistic understanding, assumptions, trade-offs, and whether you can turn a definition into a model decision.

Likely follow-up questions

What assumption makes this approach work?
When would you choose the strongest alternative instead?
What production or data failure mode changes your answer?

Common weak-answer patterns

  • Reciting a definition without mechanism or assumptions.
  • Claiming one technique is always better without a data regime.
  • Stopping before failure modes, validation, or deployment implications.