🧮 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 w⊤x=0w^\top x = 0 such that all class-1 points satisfy w⊤x>0w^\top x > 0 and all class-0 points satisfy w⊤x<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)+(1−yi)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+e−t)\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=1⇒w⊤xi>0y_i = 1 \Rightarrow w^\top x_i > 0 and yi=0⇒w⊤xi<0y_i = 0 \Rightarrow w^\top x_i < 0. Set β=tw\beta = tw for t>0t > 0. Then:

  • For yi=1y_i = 1: σ(t⋅w⊤xi)→1\sigma(t \cdot w^\top x_i) \to 1 as t→∞t \to \infty (since w⊤xi>0w^\top x_i > 0), so log⁡σ(⋅)→0\log \sigma(\cdot) \to 0.
  • For yi=0y_i = 0: σ(t⋅w⊤xi)→0\sigma(t \cdot w^\top x_i) \to 0 as t→∞t \to \infty (since w⊤xi<0w^\top x_i < 0), so log⁡(1−σ(⋅))→0\log(1 - \sigma(\cdot)) \to 0.

Therefore ℓ(tw)→0−\ell(tw) \to 0^- as t→∞t \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 ↗