Replace-one stability #
A learning rule A : (Fin m → Z) → W overfits when the risk of A S on the training sample
S is much smaller than its true risk. Replace-one stability measures how much the loss of A S
on a training example S i grows when that example is replaced by a fresh one z'
[ShalevShwartzBenDavid2014, Chapter 13]. This file proves that the two quantities agree in
expectation, and that a rule that is stable at rate ε generalizes at rate ε.
The fresh example and the sample are drawn together from (Measure.pi fun _ => D).prod D; a pair
p consists of the sample p.1 and the replacement p.2, and Function.update p.1 i p.2 is the
sample S⁽ⁱ⁾ of [ShalevShwartzBenDavid2014, Section 13.2].
Main definitions #
Cslib.MachineLearning.replaceOneGap: the expected replace-one gap𝔼_{(S, z'), i} [ℓ(A(S⁽ⁱ⁾), z_i) - ℓ(A S, z_i)].Cslib.MachineLearning.IsReplaceOneStable: on-average-replace-one stability at a given rate.
Main results #
Cslib.MachineLearning.integral_trueRisk_sub_empiricalRisk: the expected generalization gap𝔼_S [L_D(A S) - L_S(A S)]equals the expected replace-one gap [ShalevShwartzBenDavid2014, Theorem 13.2].Cslib.MachineLearning.integral_update_eval: replacing thei-th example by a fresh one and keeping the replaced example as the fresh one preserves expectations.Cslib.MachineLearning.integral_trueRisk_le_of_replaceOneGap_le: a rule whose expected replace-one gap underDis at mostεgeneralizes at rateεunderD.Cslib.MachineLearning.IsReplaceOneStable.integral_trueRisk_le: a stable rule generalizes:𝔼_S [L_D(A S)] ≤ 𝔼_S [L_S(A S)] + ε.Cslib.MachineLearning.isReplaceOneStable_of_forall_le: a rule whose loss on every example changes by at mostεwhen one example of the sample is replaced is replace-one stable at rateε.
References #
The replace-one gap #
The expected replace-one gap of a learning rule A on m examples from D: the expected
increase 𝔼_{(S, z'), i} [ℓ(A(S⁽ⁱ⁾), z_i) - ℓ(A S, z_i)] of the loss on the i-th example when
it is replaced by an independent example z', for a uniformly random index i
[ShalevShwartzBenDavid2014, Theorem 13.2]. Here S⁽ⁱ⁾ is Function.update S i z'.
Both terms are Bochner integrals, which are 0 for non-integrable integrands. So a rule whose
losses are not integrable under D has gap 0, and the gap, and stability defined from it, carry
information only for integrable losses; the results below assume integrability.
Replacing one example by a fresh one preserves expectations: for m i.i.d. examples and an
independent example z' from D, 𝔼 [g(S⁽ⁱ⁾, z_i)] = 𝔼 [g(S, z')], where S⁽ⁱ⁾ is
Function.update S i z'.
The integrability counterpart of Cslib.MachineLearning.integral_update_eval.
The expected generalization gap is the expected replace-one gap
[ShalevShwartzBenDavid2014, Theorem 13.2]: for m > 0 i.i.d. examples from D,
𝔼_S [L_D(A S) - L_S(A S)] = 𝔼_{(S, z'), i} [ℓ(A(S⁽ⁱ⁾), z_i) - ℓ(A S, z_i)].
The hypotheses ask that the loss of A S on a fresh example be integrable over the joint
distribution and its loss on each training example be integrable over the samples; they hold, for
example, for bounded losses that are jointly measurable with a measurable rule, and on finite
example spaces with measurable singletons.
Stability #
A learning rule A on m examples is on-average-replace-one stable at rate ε for the
loss ℓ if its expected replace-one gap is at most ε under every distribution D on examples
[ShalevShwartzBenDavid2014, Definition 13.3].
The source considers a family of rules, one for each sample size, with a monotonically decreasing
rate ε : ℕ → ℝ; that family is stable when IsReplaceOneStable ℓ (A m) (ε m) holds for every
m. Monotonicity is not used by any of the results and is not required here.
Stability at a rate implies stability at every larger rate.
If the expected replace-one gap of A under D is at most ε, its expected true risk exceeds
its expected empirical risk by at most ε [ShalevShwartzBenDavid2014, Theorem 13.2].
Stable rules do not overfit [ShalevShwartzBenDavid2014, Theorem 13.2 and Definition 13.3]:
if A is replace-one stable at rate ε, its expected true risk exceeds its expected empirical risk
by at most ε.
Uniform stability implies replace-one stability: if replacing any one example of any
sample changes the loss of A on every example by at most ε ≥ 0, then A is replace-one stable
at rate ε. No measurability is needed.