Explain logistic regression and why it's still used in industry
Written by the mlprep team · Updated
Explain logistic regression. Why is it still a go-to model in industry despite being decades old?
Logistic regression is a binary classifier that applies a sigmoid function to a linear combination of features:
The linear part wᵀx + b defines a hyperplane in feature space. The sigmoid squashes this to (0, 1), giving you a probability. The decision boundary — where you switch from predicting class 0 to class 1 — is exactly where wᵀx + b = 0, which is a linear boundary.
Why it's still everywhere in production#
Interpretability: each weight w_i has a direct meaning — it's the change in log-odds for a one-unit increase in feature i. In regulated industries (credit, healthcare, insurance), you can explain every prediction to a regulator or customer. That's not true of a gradient boosted tree with 500 trees, let alone a neural net.
Calibrated probabilities: logistic regression outputs are well-calibrated out of the box — if the model says 80% probability, roughly 80% of those cases are actually positive. This matters enormously in ad ranking, fraud scoring, and anything downstream that uses the probability as-is (rather than just the classification).
Speed and simplicity: training is a convex optimization problem with a unique global minimum. It trains in seconds on millions of examples. No hyperparameter search required for a first pass. Inference is a dot product + scalar function.
Strong baseline: on tabular data with good features, logistic regression is often competitive with complex models. It's common to build a logistic regression baseline first, then justify the added complexity of a more powerful model.
Limitations#
It can only learn a linear decision boundary. Non-linear relationships require either feature engineering (adding x² terms, interaction terms) or a more flexible model. Also, it assumes independence of errors and can struggle with highly correlated features — the coefficients become unreliable, even if predictions remain good.
Interview red flags#
- Calling it a regression model for continuous targets because of the name.
- Not being able to explain why cross-entropy, not MSE, is the loss: MSE on a sigmoid has vanishing gradients when the model is confidently wrong.
- Reading coefficients as feature importance without mentioning feature scaling and correlated features.
- Assuming the outputs are well-calibrated in every setting, including after class rebalancing.
You mentioned cross-entropy as the loss. Why not use MSE for classification — it's simpler and works for regression, so what's wrong with it here?
The gradient problem with MSE + sigmoid#
MSE loss is (ŷ - y)², where ŷ = σ(z) and z = wᵀx + b. The gradient with respect to z is:
The term σ(z)(1 - σ(z)) is the derivative of the sigmoid. Near z = 0 it's ~0.25, but when the model is confidently wrong — say z = 5, predicting ŷ = 0.99 for a true label y = 0 — the sigmoid is saturated and σ(z)(1 - σ(z)) ≈ 0. The gradient nearly vanishes.
This is exactly when you want the largest gradient update: the model is wrong and confident. MSE fails to punish confident wrong predictions steeply.
Cross-entropy doesn't have this problem#
Cross-entropy loss is:
The gradient with respect to z works out to simply:
The sigmoid derivative cancels out algebraically. When the model predicts ŷ = 0.99 for true label y = 0, the gradient is 0.99 — large and proportional to the error. Training is fast where it needs to be.
Convexity#
With a sigmoid output and MSE loss, the optimization landscape is non-convex — multiple local minima. With cross-entropy, it's strictly convex (under mild conditions), guaranteeing a unique global minimum that gradient descent will find.
Probabilistic interpretation#
Cross-entropy is the negative log-likelihood of the data under a Bernoulli model. Minimizing it is exactly maximum likelihood estimation — you're finding the weights that make your training data most probable under the logistic model. MSE has no clean probabilistic interpretation for classification.
The key takeaway unlocks after you reveal an expert answer.
Key Takeaway
Logistic regression applies sigmoid to a linear model, producing calibrated probabilities with an interpretable linear decision boundary. It survives in industry because it's fast, explainable, and often good enough. Cross-entropy beats MSE as a loss because sigmoid saturation kills MSE gradients exactly when the model is most wrong, while cross-entropy gradients scale cleanly with prediction error.
Follow-up Questions to Test Yourself
Interviewers often pivot here once you cover the core concept.
- How does L1 vs L2 regularization differ in effect on logistic regression coefficients, and when would you choose one over the other?
- What's the relationship between logistic regression and maximum entropy models?
- How would you extend logistic regression to a multi-class problem, and what changes in the loss function?
How confident do you feel explaining this?
Track your understanding or flag it to revisit before your next loop.
Related Questions
Explain SVMs and kernels from an interviewer's point of view
Explain ensemble methods — random forests and gradient boosting
How do decision trees split? Walk me through Gini impurity vs information gain.
Implement k-nearest neighbors with efficient distance computation