🧮 Brain Teaser

The Logistic Regression Coefficient That Goes to Infinity

Suppose you are fitting a logistic regression model to a binary classification dataset in Rp\mathbb{R}^p using maximum likelihood estimation (via gradient ascent or Newton's method). The dataset is linearly separable: there exists a hyperplane wx=0w^\top x = 0 such that all class-1 points satisfy wx>0w^\top x > 0 and all class-0 points satisfy wx<0w^\top x < 0.

Question: What happens to the maximum likelihood estimate β^\hat{\beta} as training proceeds? Does the MLE exist? What does the log-likelihood surface look like, and what does this imply about convergence of the algorithm?

logistic regressionMLEseparabilityoptimizationimplicit biasregularization

Answer: The Logistic Regression Coefficient That Goes to Infinity

Key Idea / Intuition

When the data are linearly separable, logistic regression can achieve zero training loss in the limit — but only by pushing the coefficient vector to infinity. The log-likelihood never actually attains its supremum; it approaches it asymptotically as β\|\beta\| \to \infty along the separating direction. The MLE does not exist as a finite vector. This is a clean example where the optimization problem is unbounded above on the feasible domain, yet the algorithm keeps making progress forever.


Formal Proof / Solution

Setup. The logistic regression log-likelihood for nn observations (xi,yi)(x_i, y_i) with yi{0,1}y_i \in \{0,1\} is:

(β)=i=1n[yilogσ(βxi)+(1yi)log(1σ(βxi))]\ell(\beta) = \sum_{i=1}^n \left[ y_i \log \sigma(\beta^\top x_i) + (1-y_i)\log(1-\sigma(\beta^\top x_i)) \right]

where σ(t)=1/(1+et)\sigma(t) = 1/(1+e^{-t}).

Step 1: Separability means the supremum is 0.

Note that (β)0\ell(\beta) \leq 0 always (since each term is a log of a probability (0,1)\in (0,1)), and (β)=0\ell(\beta) = 0 would require each predicted probability to be exactly 1 for class-1 points and exactly 0 for class-0 points. That would require σ(βxi)=1\sigma(\beta^\top x_i) = 1 for yi=1y_i=1 and σ(βxi)=0\sigma(\beta^\top x_i) = 0 for yi=0y_i=0, which happens only in the limit β\|\beta\| \to \infty.

Step 2: Along the separating direction, the likelihood increases without bound.

Let ww be a separating direction: yi=1wxi>0y_i = 1 \Rightarrow w^\top x_i > 0 and yi=0wxi<0y_i = 0 \Rightarrow w^\top x_i < 0. Set β=tw\beta = tw for t>0t > 0. Then:

  • For yi=1y_i = 1: σ(twxi)1\sigma(t \cdot w^\top x_i) \to 1 as tt \to \infty (since wxi>0w^\top x_i > 0), so logσ()0\log \sigma(\cdot) \to 0.
  • For yi=0y_i = 0: σ(twxi)0\sigma(t \cdot w^\top x_i) \to 0 as tt \to \infty (since wxi<0w^\top x_i < 0), so log(1σ())0\log(1 - \sigma(\cdot)) \to 0.

Therefore (tw)0\ell(tw) \to 0^- as tt \to \infty, so supβ(β)=0\sup_\beta \ell(\beta) = 0, but this supremum is never achieved at any finite β\beta.

Step 3: The MLE does not exist.

Since (β)<0\ell(\beta) < 0 for all finite β\beta (probabilities are always strictly between 0 and 1 for finite inputs), and the sup is 0, the maximum is not attained. The log-likelihood surface is unbounded — there is no finite maximizer.

Step 4: Algorithmic consequence.

Any gradient-based optimizer (gradient ascent, Newton–Raphson) will keep increasing β\|\beta\| forever:

  • The gradient never vanishes at a finite point.
  • Newton's method may diverge or oscillate.
  • Training accuracy reaches 100% quickly, but β^\|\hat\beta\| \to \infty.

The norm of β\beta grows roughly like O(t)O(t) under gradient ascent, or even faster under Newton steps.

Step 5: The implicit bias connection.

A beautiful modern observation: gradient descent on logistic loss with separable data converges in direction to the maximum-margin classifier (the SVM solution). The coefficients diverge in norm, but β/β\beta / \|\beta\| converges to the hard-margin SVM hyperplane. So logistic regression, run long enough, secretly finds the SVM solution — even without any explicit margin constraint.

Summary table:

| Condition | MLE exists? | Training loss | |-----------|-------------|--------------| | Non-separable | ✓ Finite unique MLE | > 0 | | Separable | ✗ MLE == \infty | 0\to 0 as β\|\beta\| \to \infty |

Practical implication: In separable settings, you must use regularization (e.g., 2\ell_2 penalty λβ2\lambda \|\beta\|^2) to obtain a finite, well-defined solution. Ridge-penalized logistic regression always has a unique finite minimizer.

Source: The Elements of Statistical Learning, Hastie, Tibshirani, Friedman — Chapter 4 (Linear Methods for Classification)

Type: ML/StatsSource: The Elements of Statistical Learning, Hastie, Tibshirani, Friedman — Chapter 4 (Linear Methods for Classification)Edit on GitHub ↗