PAC-Bayes bounds for countable hypothesis spaces #
A prior P over hypotheses, fixed before the sample, controls the generalization gap of every
posterior Q at once, through the Kullback–Leibler divergence KL(Q ‖ P) [McA99].
Hypotheses are indexed by a countable type ι, and ℓ i z ∈ [0, 1] is the loss of the
hypothesis i on the example z; the true and empirical risks are L_D(i) = trueRisk ℓ D i and
L_S(i) = empiricalRisk ℓ S i (Cslib.MachineLearning.trueRisk,
Cslib.MachineLearning.empiricalRisk). Under m ≥ 2 i.i.d. examples S from D and for every
δ > 0, with probability at least 1 - δ every probability measure Q on ι with
KL(Q ‖ P) < ∞ satisfies
𝔼_{i∼Q} L_D(i) ≤ 𝔼_{i∼Q} L_S(i) + √((KL(Q ‖ P) + log (m / δ)) / (2 (m - 1))),
which is [ShalevShwartzBenDavid2014, Theorem 31.1] with the source's constants. Each bound is
stated, as in the rest of the library, as an upper bound δ on the measure of the samples on
which some posterior violates it. The posterior is quantified inside that event, so it may depend
on the sample. The proof follows the source: the change-of-measure inequality
(Cslib.Probability.integral_le_toReal_klDiv_add_log_integral_exp) and Jensen's inequality bound
2 (m - 1) (𝔼_Q Δ)² - KL(Q ‖ P) by log 𝔼_P exp (2 (m - 1) Δ²) for the gap
Δ(i) = L_D(i) - L_S(i); because P does not depend on the sample, Tonelli's theorem and the
one-hypothesis exponential moment bound the sample average of the right side; Markov's inequality
finishes. The exponential moment comes from Hoeffding's lemma
(Cslib.Probability.hasSubgaussianMGF_integral_sub_sum_div) and is at most √m, sharper than the
source's m (its Exercise 31.1), so measure_pi_exists_integral_risk_gt proves the bound with
log (√m / δ) and measure_pi_exists_integral_risk_gt_log_div derives the source's form.
Taking point-mass posteriors gives the Occam bound of [ShalevShwartzBenDavid2014, Exercise 31.2]:
every hypothesis i with P {i} > 0 satisfies
L_D(i) ≤ L_S(i) + √((log (1 / P {i}) + log (m / δ)) / (2 (m - 1))), using
KL(δ_i ‖ P) = log (1 / P {i}) (Cslib.Probability.toReal_klDiv_dirac). For the uniform prior
on a finite class this is the bound with log |H| of the exercise.
Differences from the source: the hypothesis space is countable with measurable singletons (the
source also allows densities); δ < 1 is not needed; posteriors with infinite divergence are
excluded, for which the source's bound is vacuous; each ℓ i must be measurable. The divergence
is Mathlib's klDiv, in nats as in the source.
Main results #
measure_ofReal_div_le_lintegral_le_of_measurable: Markov's inequality for an average over a prior on an arbitrary measurable space, via Tonelli's theorem on a jointly measurable kernel.measure_ofReal_div_le_lintegral_le: the countable-space specialization (shared withCslib.MachineLearning.PACBayes.measure_pi_exists_binaryKL_integral_risk_gt).measure_pi_exists_integral_risk_gt_of_measurable: McAllester's bound withlog (√m / δ)on an arbitrary measurable hypothesis space (Measurable (Function.uncurry ℓ)).measure_pi_exists_integral_risk_gt: the countable-space specialization (log (√m / δ)).measure_pi_exists_integral_risk_gt_log_div: McAllester's bound with the source'slog (m / δ).measure_pi_exists_risk_gt: the Occam bound for point-mass posteriors.
References #
Markov's inequality over a prior on an arbitrary measurable space: if the nonnegative
kernel F : Ω → ι → ℝ≥0∞ is jointly measurable (Measurable (Function.uncurry F)), every
hypothesis i has 𝔼_ω F ω i ≤ B, and the prior P does not depend on ω, then
𝔼_ω 𝔼_{i∼P} F ω i ≤ B by Tonelli's theorem, so the prior average reaches B / δ with
probability at most δ.
Markov's inequality over a prior [ShalevShwartzBenDavid2014, (31.4)–(31.5)] on a
countable hypothesis space: specializes measure_ofReal_div_le_lintegral_le_of_measurable via
measurable_from_prod_countable_left.
Measurability of i ↦ trueRisk ℓ D i from joint measurability of a [0, 1]-bounded loss.
Joint measurability of (S, i) ↦ empiricalRisk ℓ S i from joint measurability of ℓ.
Measurability of i ↦ empiricalRisk ℓ S i for a fixed sample S.
Integrability of trueRisk ℓ D under any probability measure Q on ι.
Integrability of empiricalRisk ℓ S under any probability measure Q on ι.
McAllester's PAC-Bayes bound on an arbitrary measurable hypothesis space
[McA99], with log (√m / δ): for a prior P on any measurable index space ι,
jointly measurable losses ℓ i z ∈ [0, 1], m ≥ 2 and δ > 0, the samples on which some
posterior Q with KL(Q ‖ P) < ∞ has
𝔼_Q L_S + √((KL(Q ‖ P) + log (√m / δ)) / (2 (m - 1))) < 𝔼_Q L_D have probability at most δ.
McAllester's PAC-Bayes bound [McA99], with log (√m / δ): for a prior P
on a countable index, losses ℓ i z ∈ [0, 1], m ≥ 2 and δ > 0, the samples on which some
posterior Q with KL(Q ‖ P) < ∞ has
𝔼_Q L_S + √((KL(Q ‖ P) + log (√m / δ)) / (2 (m - 1))) < 𝔼_Q L_D have probability at most δ.
McAllester's PAC-Bayes bound with the constants of [ShalevShwartzBenDavid2014,
Theorem 31.1]: log (m / δ).
The Occam bound as a PAC-Bayes corollary [ShalevShwartzBenDavid2014, Exercise 31.2]:
taking point-mass posteriors, with probability at least 1 - δ every index i with P {i} > 0
satisfies L_D(i) ≤ L_S(i) + √((log (1 / P {i}) + log (m / δ)) / (2 (m - 1))).