How is logistic regression trained, and why does it have no closed-form solution like OLS linear regression?

Quick Overview

Asks how logistic regression fits its weights and why it has no closed-form solution the way ordinary least squares does. Tests the log-likelihood and its gradient, iterative solvers such as Newton's method and L-BFGS, and what convexity of the log-loss does and does not guarantee.

How is logistic regression trained, and why does it have no closed-form solution like OLS linear regression?

Role: Data Scientist

Category: Machine Learning

Difficulty: medium

Interview Round: Other

Explain how logistic regression is trained, and why it does not have a closed-form solution like ordinary least squares (OLS) linear regression. ```hint Write the condition Write the gradient of the log-likelihood, set it to zero, and compare where the weights appear with the OLS normal equations. ``` ```hint Shape of the objective Ask whether the loss can have several local minima, and what happens to the weights when the two classes are perfectly separable. ``` ### What a Strong Answer Covers - The training objective and its gradient. - How iterative solvers update the weights (gradient descent, Newton-Raphson or IRLS, L-BFGS) and when each is a sensible choice. - Why setting the gradient to zero has no algebraic solution, compared with the OLS normal equations. - What the shape of the objective guarantees about the optimum, and where that guarantee fails. ### Follow-up Questions - Write the Newton-Raphson update for logistic regression. Why is it also called iteratively reweighted least squares? - What happens to the fitted coefficients when a feature perfectly separates the classes, and how do you fix it? - Why not train logistic regression by minimizing squared error between the labels and the predicted probabilities? - With 100 million rows and 10,000 sparse features, which solver would you choose and why?

Overview: Asks how logistic regression fits its weights and why it has no closed-form solution the way ordinary least squares does. Tests the log-likelihood and its gradient, iterative solvers such as Newton's method and L-BFGS, and what convexity of the log-loss does and does not guarantee.

General logo
General
Nov 25, 2026
mediumData ScientistOtherMachine Learning
0
0

Explain how logistic regression is trained, and why it does not have a closed-form solution like ordinary least squares (OLS) linear regression.

What a Strong Answer Covers Guidance

  • The training objective and its gradient.
  • How iterative solvers update the weights (gradient descent, Newton-Raphson or IRLS, L-BFGS) and when each is a sensible choice.
  • Why setting the gradient to zero has no algebraic solution, compared with the OLS normal equations.
  • What the shape of the objective guarantees about the optimum, and where that guarantee fails.

Follow-up Questions Guidance

  • Write the Newton-Raphson update for logistic regression. Why is it also called iteratively reweighted least squares?
  • What happens to the fitted coefficients when a feature perfectly separates the classes, and how do you fix it?
  • Why not train logistic regression by minimizing squared error between the labels and the predicted probabilities?
  • With 100 million rows and 10,000 sparse features, which solver would you choose and why?