Skip to content

PAC-Bayes bound

Bound the generalisation risk of a learned distribution over predictors using empirical Gibbs risk and its KL divergence from a fixed prior.

A PAC-Bayes bound is a probabilistic generalisation guarantee for a learned distribution over predictors. It relates training loss to population loss through a penalty for moving that distribution away from a fixed prior. For a quant researcher, it makes the cost of adapting a randomised forecasting model to data explicit—under the theorem's sampling and loss assumptions.
“PAC” means probably approximately correct. Unlike a bound stated only through the size of a hypothesis class, PAC-Bayes can use the particular distribution learned from the data. Dziugaite and Roy (2017) demonstrate this approach for stochastic neural networks.

Which predictor receives the guarantee?

Let PP be a prior distribution over candidate predictors and QQ a learned distribution over the same space. A Gibbs predictor samples a predictor h∼Qh\sim Q to make its prediction. Its risk averages loss over this random draw and a fresh observation. A deterministic classifier obtained from mean weights, averaged scores or majority voting is a different object; the same risk guarantee does not transfer automatically. Dziugaite and Roy, §§1–2, make the stochastic-model distinction explicit.
The word posterior here names QQ. It need not be obtained by Bayesian inference. Any data-dependent learning procedure may choose it. By contrast, a Bayesian posterior follows likelihood times prior, normalised; Bayesian Reasoning develops that updating rule (full lesson requires membership; public preview available).

One exact PAC-Bayes-kl statement

Use the finite data and predictor spaces of Maurer's Theorem 5. Fix a loss ℓ(h,z)∈[0,1]\ell(h,z)\in[0,1], a prior PP independent of the sample, and δ∈(0,1)\delta\in(0,1). Draw S=(z1,…,zn)S=(z_1,\ldots,z_n) independently and identically from DD, with n≥8n\ge8. Define
L^S(Q)=Eh∼Q[1n∑i=1nℓ(h,zi)],LD(Q)=Eh∼QEz∼D[ℓ(h,z)].\widehat L_S(Q)=\mathbb{E}_{h\sim Q}\left[\frac1n\sum_{i=1}^n\ell(h,z_i)\right], \qquad L_D(Q)=\mathbb{E}_{h\sim Q}\mathbb{E}_{z\sim D}[\ell(h,z)].
With probability at least 1−δ1-\delta over SS, simultaneously for every distribution QQ,
kl⁡ ⁣(L^S(Q) ∥ LD(Q))≤KL⁡(Q∥P)+ln⁡(2n/δ)n.\operatorname{kl}\!\left(\widehat L_S(Q)\,\|\,L_D(Q)\right) \le \frac{\operatorname{KL}(Q\|P)+\ln(2\sqrt n/\delta)}{n}.

This simultaneous guarantee permits choosing QQ after seeing SS. The confidence concerns repeated training samples, rather than a posterior probability that an individual fitted model is correct. Finite spaces keep measurability simple; continuous-space versions require the corresponding measurable setup.

Two KL quantities, two jobs

The left side compares Bernoulli distributions whose means are risks:
kl⁡(a∥b)=aln⁡ab+(1−a)ln⁡1−a1−b.\operatorname{kl}(a\|b) =a\ln\frac ab+(1-a)\ln\frac{1-a}{1-b}.

At zero and one, use the limiting conventions: a zero-mass term contributes zero; positive mass against a comparison event of probability zero gives infinite divergence.

The right side uses relative entropy between distributions over predictors. These are different arguments of the same divergence construction, not interchangeable inputs. The Bernoulli expression is valid for bounded risks even when individual losses are not binary. To upper-bound population risk, find the largest admissible value b∈[0,1]b\in[0,1] satisfying the kl inequality for the observed empirical risk. Dziugaite and Roy (2018), §4, distinguish these quantities and describe this inversion.

Consider two fictional predictors, A and B. Give each prior probability 0.50.5, then learn posterior probabilities 0.750.75 and 0.250.25. Using natural logarithms,

KL⁡(Q∥P)=∑h∈{A,B}Q(h)ln⁡Q(h)P(h)=0.75ln⁡(1.5)+0.25ln⁡(0.5)≈0.130812 nats.\begin{aligned} \operatorname{KL}(Q\|P) &=\sum_{h\in\{A,B\}}Q(h)\ln\frac{Q(h)}{P(h)}\\ &=0.75\ln(1.5)+0.25\ln(0.5)\\ &\approx0.130812\text{ nats}. \end{aligned}

The B contribution is negative; only their sum must be nonnegative. These weights are probabilities of sampling predictors, not portfolio allocations. The result alone says nothing about the predictors' losses: sample size, confidence and empirical Gibbs risk are still needed for a numerical risk bound. Putting posterior mass where the prior assigns zero makes the KL penalty infinite.

Illustrative two-predictor example: prior weights are 0.5 and 0.5; posterior weights are 0.75 and 0.25. KL(Q relative to P) is 0.130812 nats. This predictor-space penalty differs from Bernoulli kl comparing empirical and population Gibbs risks.
Illustrative two-predictor example: prior weights are 0.5 and 0.5; posterior weights are 0.75 and 0.25. KL(Q relative to P) is 0.130812 nats. This predictor-space penalty differs from Bernoulli kl comparing empirical and population Gibbs risks.
Original illustrative example. The bars show probabilities of sampling predictors A and B. The numerical calculation is the posterior-to-prior KL penalty only; no risk bound is calculated.

The prior cannot quietly follow the same sample

Setting P=QP=Q after fitting would erase the penalty, but violates the fixed-prior theorem. Valid data-dependent-prior results exist: Dziugaite and Roy (2018), Theorem 4.2, use a differentially private prior-selection mechanism and add terms to the bound. Such a result needs its own conditions; it is not permission to substitute a fitted prior into the displayed formula.
For financial data, serial dependence, overlapping labels and changing regimes obstruct the i.i.d. premise. Unbounded return-based loss also falls outside this statement; bounding or clipping loss changes the target being certified. A small penalty alone neither establishes useful generalisation nor certifies future trading returns.

Sources

Last updated
  • learning theory
  • pac bayes
  • generalisation
  • relative entropy
  • randomised predictors
← Back to the glossaryBack to top ↑