🧮 Brain Teaser
2026-08-16
✏︎

The Overconfident Classifier: When More Data Hurts Calibration

You train a logistic regression model on a dataset with pp features and nn training examples, where pp is large relative to nn. The model achieves near-zero training loss.

A colleague suggests: "The model's predicted probabilities are well-calibrated — after all, we minimized cross-entropy, which directly targets the log-likelihood of probabilities."

Question: Is this reasoning correct? Specifically:

  1. When p/nc>0p/n \to c > 0 (i.e., the number of features is a constant fraction of the sample size), what happens to the maximum likelihood estimates β^\hat{\beta} in logistic regression, and why does this make predicted probabilities systematically overconfident (pushed toward 0 and 1)?

  2. Give a simple, clean argument for why minimizing training cross-entropy does not guarantee calibrated probabilities, even in principle — using just the concept of overfitting and the difference between training and test distributions.

  3. (Bonus conceptual punchline): What simple post-hoc fix can partially restore calibration, and why does it work geometrically?

Answer: 2026-08-16_am

Key Idea / Intuition

Minimizing cross-entropy on training data is a maximum likelihood procedure — it finds β^\hat{\beta} that makes the training labels look as probable as possible. When features are plentiful relative to data points (p/np/n not negligible), the MLE overshoots: it inflates the magnitude of β^\hat{\beta} to push training probabilities toward 0 and 1, fitting the noise. On new data, these extreme predicted probabilities are systematically wrong — the model is overconfident. The fix is elegant: just rescale (divide) the logit by a temperature T>1T > 1, which geometrically "squashes" the sigmoid back toward the center.


Formal Proof / Solution

Part 1: What Happens When p/nc>0p/n \to c > 0

Setup. In logistic regression, we maximize the log-likelihood: (β)=i=1n[yilogσ(xiβ)+(1yi)log(1σ(xiβ))]\ell(\beta) = \sum_{i=1}^n \left[ y_i \log \sigma(x_i^\top \beta) + (1-y_i)\log(1 - \sigma(x_i^\top \beta)) \right] where σ(t)=1/(1+et)\sigma(t) = 1/(1+e^{-t}).

The classical regime (pp fixed, nn \to \infty): MLE is consistent, β^β\hat{\beta} \to \beta^*.

The proportional regime (p/nc(0,1)p/n \to c \in (0,1)): A landmark result (Sur & Candès, 2019, building on earlier work) shows that MLE is not consistent. Specifically:

  • The MLE exists and is finite only when the data are not perfectly separable.
  • But even when it exists, β^\|\hat{\beta}\| is systematically inflated relative to β\|\beta^*\| by a factor >1> 1 that depends on cc.
  • Intuitively: with pcnp \approx cn free parameters, the optimizer finds directions in Rp\mathbb{R}^p that separate training points better than the truth does.

Consequence for probabilities. The predicted probability for a new point xx is: p^(x)=σ(xβ^)\hat{p}(x) = \sigma(x^\top \hat{\beta})

Since β^>β\|\hat{\beta}\| > \|\beta^*\|, the logits xβ^x^\top \hat{\beta} are inflated in magnitude, pushing p^(x)\hat{p}(x) toward 0 or 1 even when the true probability is moderate (say, 0.6 or 0.4). This is overconfidence.

A toy example to see it clearly. Suppose the true β=e1\beta^* = e_1 (unit vector), but the MLE returns β^=2e1\hat{\beta} = 2e_1. Then:

  • True probability at x=(1,0,,0)x = (1, 0, \ldots, 0): σ(1)0.73\sigma(1) \approx 0.73
  • Predicted probability: σ(2)0.88\sigma(2) \approx 0.88

The model is far more confident than it should be.


Part 2: Training Cross-Entropy Minimization ≠ Calibration

The clean argument:

Calibration means: among all examples where the model predicts probability pp, approximately fraction pp should actually be positive. Formally, we want: P(Y=1p^(X)=p)=pfor all p[0,1].\mathbb{P}(Y = 1 \mid \hat{p}(X) = p) = p \quad \text{for all } p \in [0,1].

Training cross-entropy minimization gives us: β^=argminβ1ni=1n[yilogp^(xi)+(1yi)log(1p^(xi))]\hat{\beta} = \arg\min_\beta - \frac{1}{n}\sum_{i=1}^n \left[ y_i \log \hat{p}(x_i) + (1-y_i)\log(1-\hat{p}(x_i)) \right]

This only enforces that predictions match training labels, not the true conditional distribution. Specifically:

  • If the model overfits, it memorizes training labels. A training point with yi=1y_i = 1 gets p^(xi)1\hat{p}(x_i) \approx 1 even if the true P(Y=1xi)=0.7P(Y=1 \mid x_i) = 0.7.
  • The empirical cross-entropy is minimized, but the population cross-entropy (which would ensure calibration) is not.

Formally, perfect calibration requires: E(X,Y)Ptest[logp^(X)Y(1p^(X))1Y]\mathbb{E}_{(X,Y)\sim P_{\text{test}}}[-\log \hat{p}(X)^Y (1-\hat{p}(X))^{1-Y}] to be minimized over the test distribution, not the training distribution.

Overfitting breaks this: minimizing training loss inflates β^\hat{\beta}, and the resulting p^\hat{p} is no longer the minimizer of the population cross-entropy.


Part 3 (Bonus): Temperature Scaling

The fix: After training, find a scalar T>1T > 1 and replace all predicted logits z=xβ^z = x^\top \hat{\beta} with z/Tz/T: p^calibrated(x)=σ ⁣(xβ^T)\hat{p}_{\text{calibrated}}(x) = \sigma\!\left(\frac{x^\top \hat{\beta}}{T}\right)

TT is chosen to minimize cross-entropy on a held-out validation set.

Why it works — geometrically:

The sigmoid σ(t)\sigma(t) maps R(0,1)\mathbb{R} \to (0,1). Dividing by T>1T > 1 compresses the logit, which moves predicted probabilities away from the extremes (0 and 1) toward the center (0.5).

σ(t/T)0.5 as T,σ(t/T)σ(t) as T1\sigma(t/T) \longrightarrow 0.5 \text{ as } T \to \infty, \qquad \sigma(t/T) \to \sigma(t) \text{ as } T \to 1

This is the Platt scaling idea. It doesn't change the model's ranking of predictions (monotone transformation), only their magnitude — correcting the systematic overconfidence from inflated β^\|\hat{\beta}\| without retraining.

Why T>1T > 1 (not T<1T < 1)? Modern neural networks and logistic regression in high dimensions are overconfident (not underconfident), so we need to flatten the distribution, not sharpen it. T>1T > 1 does exactly this.


Summary Table

| Regime | β^\hat{\beta} behavior | Calibration | |---|---|---| | pnp \ll n | Consistent | Good | | p/nc>0p/n \to c > 0 | Inflated magnitude | Overconfident | | p>np > n, separable | β^\|\hat{\beta}\| \to \infty | Completely broken | | After temperature scaling | Logits divided by T>1T > 1 | Restored |

Written to: question file