Why does logistic regression use binary cross-entropy (log loss), and why is mean squared error unsuitable?

Quick Overview

Asks why logistic regression is trained with binary cross-entropy and what goes wrong when mean squared error is used instead. Tests the maximum likelihood view of log loss, its gradient and convexity, and how the sigmoid interacts with each loss when the model is confidently wrong.

Why does logistic regression use binary cross-entropy (log loss), and why is mean squared error unsuitable?

Role: Data Scientist

Category: Machine Learning

Difficulty: medium

Interview Round: Other

Why is binary cross-entropy (log loss) used as the cost function for logistic regression, and why is mean squared error unsuitable? ```hint Start from the model Logistic regression models each label as a Bernoulli draw with probability $\sigma(w^\top x)$. Write down the likelihood of the training labels and see what loss falls out. ``` ```hint Compare the gradients Differentiate both losses with respect to the logit $z$. Look at what happens to each gradient when the model is confidently wrong, for example $y = 1$ and $p$ close to 0. ``` ### What a Strong Answer Covers - The link between log loss and maximum likelihood for a Bernoulli outcome - The gradient of log loss and why the sigmoid derivative cancels - Convexity of log loss in the weights, and what MSE through a sigmoid does to the optimization surface - How each loss treats confident wrong predictions, ideally with numbers - Why the Gaussian-noise assumption behind MSE does not fit 0/1 labels ### Follow-up Questions - What happens to logistic regression weights trained with log loss on perfectly separable data, and how do you fix it? - The Brier score is MSE on predicted probabilities. Why is it fine as an evaluation metric when MSE is a poor training loss? - How do you compute log loss without overflow or `log(0)` when the logits are large? - How does the argument generalize to softmax regression with categorical cross-entropy?

Overview: Asks why logistic regression is trained with binary cross-entropy and what goes wrong when mean squared error is used instead. Tests the maximum likelihood view of log loss, its gradient and convexity, and how the sigmoid interacts with each loss when the model is confidently wrong.

Nov 25, 2026
mediumData ScientistOtherMachine Learning
0
0

Why is binary cross-entropy (log loss) used as the cost function for logistic regression, and why is mean squared error unsuitable?

What a Strong Answer Covers Guidance

  • The link between log loss and maximum likelihood for a Bernoulli outcome
  • The gradient of log loss and why the sigmoid derivative cancels
  • Convexity of log loss in the weights, and what MSE through a sigmoid does to the optimization surface
  • How each loss treats confident wrong predictions, ideally with numbers
  • Why the Gaussian-noise assumption behind MSE does not fit 0/1 labels

Follow-up Questions Guidance

  • What happens to logistic regression weights trained with log loss on perfectly separable data, and how do you fix it?
  • The Brier score is MSE on predicted probabilities. Why is it fine as an evaluation metric when MSE is a poor training loss?
  • How do you compute log loss without overflow or log(0) when the logits are large?
  • How does the argument generalize to softmax regression with categorical cross-entropy?