Tutorials › Statistical Learning (Graduate) › PAC-Bayes Risk Bounds for Squared-Error Regression

PAC-Bayesian Generalization · Tutorial 365 of 989

PAC-Bayes Risk Bounds for Squared-Error Regression

Translate bounded squared-error regression into a PAC-Bayes risk guarantee, with explicit calculations of empirical Gibbs risk, divergence, and the confidence penalty.

Advanced 12 min read

What You'll Learn

  • State the range conditions that make squared-error loss bounded.
  • Normalize squared error so it lies between zero and one.
  • Apply the PAC-Bayes-KL inequality to a posterior over regression predictors.
  • Calculate empirical Gibbs risk by averaging squared losses over data and predictors.
  • Compute the prior-to-posterior Kullback–Leibler divergence and confidence penalty.
  • Interpret the bound and recognize when clipping or rescaling changes the problem.

Why Squared-Error PAC-Bayes Bounds Need a Range

Squared-error regression is familiar, but its loss is not automatically bounded: if either the outcome or a predictor’s output can grow without limit, then \((h(X)-Y)^2\) can also grow without limit. A bounded-loss PAC-Bayes inequality therefore applies only after the outcome and predictions have been restricted to a common finite interval, or after a justified transformation that gives a bounded loss. The range is part of the statistical model, not a technical detail that can be ignored.

Let \((X,Y)\) have distribution \(\mathcal D\), and let a sample \(S=((X_1,Y_1),\ldots,(X_n,Y_n))\) consist of independent observations from \(\mathcal D\). A predictor \(h\) maps an input \(x\) to a numerical prediction. We consider a prior distribution \(P\) over a measurable predictor class, fixed independently of \(S\), and a posterior distribution \(Q\), which may depend on \(S\). Assume that, for fixed finite \(L<U\), outcomes satisfy \(Y\in[L,U]\) almost surely and every predictor in the support of \(P\) and \(Q\) predicts in \([L,U]\) on the input domain of interest. Write \(D=U-L>0\).

Definition: The normalized squared-error loss is \(\ell_h(x,y)=(h(x)-y)^2/D^2\). The Gibbs population risk and empirical Gibbs risk of \(Q\) are \(R(Q)=E_{h\sim Q}E_{(X,Y)\sim\mathcal D}[\ell_h(X,Y)]\) and \(\hat R_S(Q)=E_{h\sim Q}\left[\frac{1}{n}\sum_{i=1}^n\ell_h(X_i,Y_i)\right]\). The Kullback–Leibler divergence from \(Q\) to \(P\) is \(\operatorname{KL}(Q\|P)=E_{h\sim Q}[\log(dQ/dP)(h)]\) when \(Q\) is absolutely continuous with respect to \(P\), and is infinite otherwise.

Because both \(h(x)\) and \(y\) lie in an interval of width \(D\), their absolute difference is at most \(D\). Thus \(0\leq\ell_h(x,y)\leq1\). This normalization lets us use a bounded-loss result directly. It also gives an exact conversion back to the original squared-error scale: \(D^2R(Q)\) is the expected Gibbs squared error in the original units.

The PAC-Bayes-KL Bound for Squared Error

We use the PAC-Bayes-KL inequality. It applies to a bounded loss and provides one event on which the guarantee holds simultaneously for every posterior, including a posterior selected after observing the sample. For \(a,b\in[0,1]\), define the binary relative entropy by \(\operatorname{kl}(a\|b)=a\log(a/b)+(1-a)\log((1-a)/(1-b))\), with the usual continuous endpoint conventions.

Theorem: Suppose \(S\) consists of \(n\) independent observations from \(\mathcal D\), the loss is measurable and takes values in \([0,1]\), and the prior \(P\) is fixed independently of \(S\). For any \(0<\delta<1\), with probability at least \(1-\delta\) over \(S\), simultaneously for every posterior \(Q\), \[ \operatorname{kl}\bigl(\hat R_S(Q)\|R(Q)\bigr) \leq \frac{\operatorname{KL}(Q\|P)+\log(2\sqrt n/\delta)}{n}. \] For squared-error regression under the range conditions above, this theorem applies to the normalized loss \(\ell_h\).

The right-hand side has two components. The divergence term measures how far the chosen posterior moves from the prior; the confidence term depends on sample size and the requested failure probability. Let \(c_Q=(\operatorname{KL}(Q\|P)+\log(2\sqrt n/\delta))/n\). On the stated event, the binary relative entropy is bounded above by \(c_Q\). This is a constraint on the pair of risks, not an additive risk-gap bound. In particular, a large \(c_Q\) can make the implied risk guarantee weak; it does not change the fact that the inequality bounds binary relative entropy by \(c_Q\).

For a convenient upper-risk interpretation, fix \(r=\hat R_S(Q)\) and define \(q_{\mathrm{up}}(r,c)=\sup\{q\in[r,1]:\operatorname{kl}(r\|q)\leq c\}\). The PAC-Bayes-KL inequality implies \(R(Q)\leq q_{\mathrm{up}}(r,c_Q)\). The endpoint \(q=1\) is included, so the definition remains meaningful when the constraint is too weak to improve on the trivial bound. In original squared-error units, the resulting upper bound is \(D^2q_{\mathrm{up}}(r,c_Q)\).

What Is Being Averaged?

The empirical Gibbs risk averages in two stages: first the observed normalized squared loss is averaged over the sample, then that quantity is averaged over predictors drawn from \(Q\). If \(h_1,\ldots,h_m\) have posterior probabilities \(q_1,\ldots,q_m\), then \(\hat R_S(Q)=\sum_{j=1}^m q_j\hat R_S(h_j)\), where \(\hat R_S(h_j)=n^{-1}\sum_{i=1}^n\ell_{h_j}(X_i,Y_i)\). This is the risk of a randomly drawn predictor under the posterior, averaged over that draw. It is not obtained by squaring an average residual: averaging squared losses and squaring an average prediction are generally different operations.

Worked Example: Normalizing and Averaging Squared Errors

Suppose outcomes and predictions lie in \([0,10]\), so \(D=10\). On four observations, predictor \(h_1\) has residuals \(1,2,0,3\), and \(h_2\) has residuals \(4,1,2,0\). Let the posterior assign probabilities \(0.75\) and \(0.25\), respectively.

For \(h_1\), the squared residuals sum to \(1+4+0+9=14\). Its mean raw squared error is \(14/4=3.5\), and its normalized empirical risk is \(3.5/100=0.035\).

For \(h_2\), the squared residuals sum to \(16+1+4+0=21\). Its mean raw squared error is \(21/4=5.25\), and its normalized empirical risk is \(5.25/100=0.0525\).

Therefore the empirical Gibbs risk is \(0.75(0.035)+0.25(0.0525)=0.02625+0.013125=0.039375\). On the raw squared-error scale it is \(100(0.039375)=3.9375\), which also equals \(0.75(3.5)+0.25(5.25)\). The matching calculations verify both the averaging and the scale conversion.

Derived result: If \(\hat R^{\mathrm{raw}}_S(Q)=E_{h\sim Q}[n^{-1}\sum_i(h(X_i)-Y_i)^2]\) and \(R^{\mathrm{raw}}(Q)=E_{h\sim Q}E_{\mathcal D}[(h(X)-Y)^2]\), then \(\hat R_S(Q)=\hat R^{\mathrm{raw}}_S(Q)/D^2\) and \(R(Q)=R^{\mathrm{raw}}(Q)/D^2\). Consequently, the PAC-Bayes-KL guarantee for the normalized risks gives \(R^{\mathrm{raw}}(Q)\leq D^2q_{\mathrm{up}}(\hat R^{\mathrm{raw}}_S(Q)/D^2,c_Q)\).

To verify the conversion, the definition of normalized loss gives \(\ell_h(x,y)=(h(x)-y)^2/D^2\) for every predictor, input, and outcome under consideration. Taking the empirical average and then the expectation over \(Q\) preserves division by the constant \(D^2\), giving the first identity. Taking population expectation and posterior expectation gives the second identity for the same reason. Substituting the normalized empirical risk into the upper-risk form of the theorem gives the displayed raw-scale guarantee. No assumption about the posterior beyond those in the theorem is added by this rescaling. \(\square\)

Worked Risk-Bound Calculations

Worked Example: Turning the KL Constraint Into a Risk Limit

Suppose \(n=100\), \(\delta=0.05\), \(\operatorname{KL}(Q\|P)=0.1\), and the observed normalized empirical Gibbs risk is \(0.04\). The confidence and divergence threshold is \(c_Q=(0.1+\log(2\sqrt{100}/0.05))/100\). Since \(2\sqrt{100}/0.05=400\) and \(\log(400)\approx5.991465\), this gives \(c_Q\approx0.06091465\).

To obtain a simple risk statement, evaluate the binary relative entropy at \(q=0.15\): \(\operatorname{kl}(0.04\|0.15)=0.04\log(0.04/0.15)+0.96\log(0.96/0.85)\). The first term is approximately \(-0.052870\), and the second is approximately \(0.116829\), so the total is approximately \(0.063959\), which exceeds \(c_Q\).

For fixed \(r=0.04\), the derivative of \(\operatorname{kl}(r\|q)\) with respect to \(q\) is \((q-r)/(q(1-q))\), which is positive for \(q>r\). Thus any \(q\geq0.15\) has binary relative entropy greater than \(c_Q\). On the PAC-Bayes event, \(R(Q)<0.15\). If the original outcome and prediction interval were \([0,10]\), this implies raw Gibbs mean squared error below \(100(0.15)=15\). The threshold is valid but is not necessarily sharp; the exact upper endpoint can be found by numerically inverting the binary relative entropy.

Worked Example: Calculating a Finite-Predictor Divergence Penalty

Consider three predictors and prior probabilities \(P=(0.5,0.3,0.2)\). Let the posterior be \(Q=(0.7,0.2,0.1)\). Their divergence is \(\operatorname{KL}(Q\|P)=0.7\log(0.7/0.5)+0.2\log(0.2/0.3)+0.1\log(0.1/0.2)\).

The three contributions are approximately \(0.7\log(1.4)=0.235531\), \(0.2\log(2/3)=-0.081093\), and \(0.1\log(0.5)=-0.069315\). Their sum is approximately \(0.085123\). Individual contributions can be negative; the divergence is their total, which here is positive.

Suppose \(n=1000\), \(\delta=0.05\), and the predictors’ normalized empirical risks are \(0.04,0.09,0.16\). The empirical Gibbs risk is \(0.7(0.04)+0.2(0.09)+0.1(0.16)=0.028+0.018+0.016=0.062\). The theorem’s threshold is \((0.085123+\log(2\sqrt{1000}/0.05))/1000\). Here \(2\sqrt{1000}/0.05\approx1264.911\), whose logarithm is approximately \(7.143\), giving \(c_Q\approx0.00723\). Thus, with probability at least \(0.95\), the binary relative entropy between \(0.062\) and the normalized population Gibbs risk is at most approximately \(0.00723\), simultaneously with the theorem’s guarantee for every posterior. The empirical calculation alone does not assert that the population risk equals \(0.062\).

Derived result: For a finite predictor class with probabilities \(q_j=Q(h_j)\), the empirical Gibbs risk is \(\sum_j q_j\hat R_S(h_j)\), and the divergence is \(\sum_jq_j\log(q_j/p_j)\), provided \(q_j>0\) only where \(p_j>0\). The first identity follows by expanding the posterior expectation of the finite sum of sample losses: \(E_{h\sim Q}[n^{-1}\sum_i\ell_h(X_i,Y_i)]=\sum_jq_j[n^{-1}\sum_i\ell_{h_j}(X_i,Y_i)]\). The second follows because the density ratio at \(h_j\) is \(q_j/p_j\), so its expectation under \(Q\) is \(\sum_jq_j\log(q_j/p_j)\). If some \(q_j>0\) while \(p_j=0\), absolute continuity fails and the divergence is infinite. \(\square\)

Range Choices, Interpretation, and a Common Pitfall

The range assumption determines the scale of the guarantee. If an outcome is known to lie in \([L,U]\), constrain predictions to that same interval to obtain the normalized loss above. In practice, clipping a raw prediction to \([L,U]\) can enforce this condition, but it changes the predictor: the resulting guarantee concerns the clipped predictor. If predictions or outcomes can fall outside the interval, the claimed pointwise loss bound may fail. One cannot justify a bounded-loss theorem merely by noting that observed residuals in a particular sample were small.

The bound controls the posterior-averaged risk of a Gibbs predictor. Its empirical side must therefore average squared loss over the posterior, not substitute a single favored predictor unless the posterior is actually concentrated on it. A posterior with small empirical risk can still incur a substantial divergence penalty if it puts weight on predictors that were unlikely under the prior. Conversely, increasing the sample size reduces the contribution of a fixed divergence and confidence term through division by \(n\); this does not remove the need for representative independent observations or correct range conditions.

Common mistake: It is tempting to calculate unnormalized squared errors and insert them directly into a PAC-Bayes-KL inequality, or to assert that bounded observed errors make the loss bounded. The correction is to establish a population-level range condition first, divide squared error by \(D^2\), and apply the theorem to a loss in \([0,1]\). Only after obtaining the normalized risk statement should it be multiplied by \(D^2\) to return to the original units. The binary relative entropy is bounded above by \(c_Q\) on the theorem’s event; a weak threshold makes the resulting risk information weak, but does not erase or alter that inequality.

Key takeaway: A squared-error PAC-Bayes guarantee requires explicit bounds on both outcomes and predictions. Once squared error is normalized by the squared interval width, the PAC-Bayes-KL inequality applies to the posterior Gibbs risk, with empirical fit and prior-to-posterior divergence both entering the guarantee.

Check Your Understanding

Use the definitions and calculations above to answer these questions.

  1. If outcomes and predictions lie in \([-2,3]\), what constant normalizes squared error to lie in \([0,1]\)?
  2. For a finite posterior, why is the empirical Gibbs risk a weighted average of each predictor’s empirical risk?
  3. With \(n=100\), \(\delta=0.05\), and \(\operatorname{KL}(Q\|P)=0\), write the PAC-Bayes-KL threshold before evaluating it.
  4. Why is it not valid to claim a bounded-loss PAC-Bayes guarantee just because all residuals in the observed sample are small?
  5. If a normalized population Gibbs risk is bounded above by \(q\) and the common outcome-prediction interval has width \(D\), what is the corresponding bound on raw mean squared error?
Clinical Biostats