Machine Learning Engineer Interview Question

How do you choose a loss function, and when would you use something other than the default?

What the interviewer is probing, how to structure your answer, and a spoken example you can adapt.

Quick answer

Choose the loss that matches the decision and the cost of being wrong, not the one the tutorial used. Cross entropy for classification when you need calibrated probabilities, mean squared error when large errors are disproportionately bad, mean absolute error or Huber when outliers should not dominate, focal loss for extreme imbalance, and a quantile or pinball loss when you need a specific percentile rather than a mean.

Why interviewers ask this

The loss is the only thing the model actually optimizes, so this reveals whether you connect training to the business objective. Interviewers listen for a case where you moved off the default and why, especially around outliers and imbalance. Explaining that MSE fits the conditional mean while MAE fits the median, and pinball loss fits a chosen quantile, is the level of precision they want.

How to structure your answer

  • State that the loss should encode the cost of being wrong.
  • Contrast MSE, MAE, and Huber on outlier sensitivity.
  • Give one imbalance case and one quantile case.
  • Warn that a reweighted loss can break probability calibration.

Example answer

Spoken example, first person

The loss is the only thing the model actually optimizes, so it should encode what a mistake costs us. On regression, MSE fits the conditional mean and punishes big misses quadratically, which is right if a large error really is disproportionately bad. It also means a handful of outliers can dominate the entire fit. MAE fits the median and is far more robust, and Huber gives quadratic behavior near zero with linear tails, which is my usual default on messy real world targets. The case I remember best was a delivery time model. We trained on MSE, and the predictions were fine on average and useless operationally, because what the business needed was a time they could promise, which is roughly the 90th percentile. Switching to a pinball loss at 0.9 gave exactly that and the late rate dropped sharply, with no architecture change at all. On classification I stay with cross entropy unless imbalance is severe, where focal loss downweights the easy negatives so the hard ones actually contribute. The thing I always check afterward is calibration, because anything that reweights the loss distorts the output probabilities.

Walking into this interview soon? GhostPilot listens to your live call, spots the question the moment it is asked, and puts a structured answer on your screen in real time. Try it on your next mock, or grab a $29 Session Pass, no subscription, for the real thing.

See how it works

Follow-up questions to expect

  • What does the delta parameter in Huber loss control?
  • How would you build a custom loss with asymmetric error costs?
  • How do you restore calibration after training with focal loss?

Related machine learning engineer questions

Your interviewer will ask their own version of this. Paste your actual job description into the free Question Predictor and get the 20 questions that role is most likely to ask, with what each one is really probing.

Predict my questions

Rehearse the hard questions before they are asked

Practise with a live copilot, then walk in ready. A $29 Session Pass gets you through the interview with no subscription and no lock-in.

Get GhostPilot