Chapter 15 Stability

We’ve argued that it’s important to consider algorithm-specific bounds: sometimes ℋ is too big for uniform convergence, but 𝒜 still learns well. This is true both for deep learning and for, say, kernel ridge regression with a universal kernel,

arg⁢minh∈ℱ⁡LS𝑠𝑞⁢(h)+λ2⁢∥h∥ℱ2.

This algorithm could feasibly return any h∈ℱ ,111Consider a 𝒟 where y∣x=h∗⁢(x) , the distribution on x is “sufficiently broad,” and λ→0 as m→∞ . If this kernel is also continuous, h∗ is the unique minimizer of L𝒟 , and checking the details in some asymptotic analysis will give us that h^S→h∗ . and so a typical uniform convergence analysis will have to use ℋ=ℱ . But we know that the VC dimension and Rademacher complexity of ℱ are both infinite for a universal kernel, so a uniform convergence analysis won’t tell us anything useful.

We can generalize this setting a bit to regularized loss minimization (RLM):

arg⁢minh∈ℋ⁡LS⁢(h)+λ⁢R⁢(h). (RLM)

(Kernel ridge regression uses square loss, with ℋ the RKHS ℱ , and R⁢(h)=12⁢∥h∥ℱ2 . We’ll use the factor of 1/2 because it makes R 1-strongly convex, as in proposition C.9.)

We’ve appealed before to a connection between RLM and constrained ERM:

arg⁢minh∈ℋ:R⁢(h)≤B⁡LS⁢(h).

The two problems are Lagrange dual to each other: for any λ , there is some B such that the solutions agree, and vice versa. But converting between λ and B generally requires actually solving the problem, (RLM) is typically easier computationally, and it’s usually easier to choose a good λ than to choose a good B . So, we’d like to come up with a direct analysis of (RLM) for its own sake, in addition to developing techniques that will help with other analyses.

Randomized algorithms

Our analyses of ERM applied to any empirical risk minimizer, so exactly what the algorithm did didn’t really matter. When we’re dealing with specific algorithms, though, it’s important to note that these algorithms might be randomized: for instance, stochastic gradient descent sees points in a random order, and might start at a random location.

Notationally, we’ll use 𝒜⁢(S) to denote the potentially random result of the algorithm on a set S : even for a fixed S , the result could be a random variable. Something like 𝔼𝒜ℓ⁢(𝒜⁢(S),z) will denote the mean of the loss on a fixed z when training on a fixed S . We’ll always assume that this randomness is independent of S (other than its size): for instance, this will be the random seed that determines that pattern in which we access the zi . If 𝒜 is deterministic, it’s just a point-mass distribution.

15.1 Definitions of Stability

The general intuition we’re going to use is algorithmic stability: if two training sets S and S′ are “similar,” then 𝒜⁢(S) and 𝒜⁢(S′) will also be “similar.” Then 𝒜 doesn’t “depend too much” on the particular sample set, and so it’s likely to not really overfit too much. (Defining “similar” in different ways will yield different notions of stability.)

In (RLM), the regularizer R⁢(h) “stabilizes” the algorithm. For instance, if you run linear regression on “multicollinear” data (where the n×d data matrix isn’t full rank), there are multiple possible solutions: the algorithm isn’t stable. But if you add the regularizer λ⁢∥w∥2 , then there’s always a unique solution that doesn’t depend too much on any one input point.

We’ll use the following notation for changing single sample points:

If ⁢S=(z1,…,zm), then ⁢S(i←z′)=(z1,…,zi−1,z′,zi+1,…,zm).

Now, notice the following basically-trivial result:

Proposition 15.1.

For any distribution 𝒟 and learning algorithm 𝒜 ,

𝔼S∼𝒟m,𝒜[L𝒟⁢(𝒜⁢(S))−LS⁢(𝒜⁢(S))]=𝔼S∼𝒟m,z′∼𝒟i∼Unif⁡([m]),𝒜[ℓ⁢(𝒜⁢(S(i←z′)),zi)−ℓ⁢(𝒜⁢(S),zi)].

On the right-hand side, the first loss term is the generalization loss, since 𝒜⁢(S(i←z′)) doesn’t train on zi . The second one is the training error, since 𝒜⁢(S) does train on zi .

Proof.

Splitting up the expectation, the second term has

𝔼S∼𝒟mi∼Unif⁡([m]),𝒜[ℓ⁢(𝒜⁢(S),zi)]=𝔼S∼𝒟m,𝒜[1m⁢∑i=1mℓ⁢(𝒜⁢(S),zi)]=𝔼S∼𝒟m,𝒜[LS⁢(𝒜⁢(S))].

The first is

𝔼S∼𝒟m,z′∼𝒟i∼Unif⁡([m]),𝒜[ℓ⁢(𝒜⁢(S(i←z′)),zi)]=𝔼S∼𝒟m,z′∼𝒟i∼Unif⁡([m]),𝒜[ℓ⁢(𝒜⁢(S),z′)]=𝔼S∼𝒟m,𝒜L𝒟⁢(𝒜⁢(S)),

where we switched the names of the iid variables zi and z′ in the first equality. ∎

This motivates what is basically the weakest useful notion of stability:

Definition 15.2.

𝒜 is ε⁢(m) -on-average-replace-one stable if for all 𝒟 ,

𝔼S∼𝒟m,z′∼𝒟i∼Unif⁡([m]),𝒜[ℓ⁢(𝒜⁢(S(i←z′)),zi)−ℓ⁢(𝒜⁢(S),zi)]≤ε⁢(m).

We say an algorithm is on-average-replace-one stable if limm→∞ε⁢(m)=0 for all 𝒟 .

Thus, an ε⁢(m) -on-average-replace-one stable algorithm will have small average-case generalization gap L𝒟⁢(𝒜⁢(S))−LS⁢(𝒜⁢(S)) : it won’t overfit much, on average. Like for uniform convergence, there are bad stable algorithms: consider 𝒜 that always returns x↦0 regardless of S . But a stable algorithm that also usually fits its training data, one with small 𝔼SLS⁢(𝒜⁢(S)) , will have small 𝔼SL𝒟⁢(𝒜⁢(S)) . This is the notion studied by Chapter 13 of [SB14]; also see [SSS+10].

Notice that since proposition 15.1 is an equality, any algorithm where 𝔼SL𝒟⁢(𝒜⁢(S)) is always close to 𝔼SLS⁢(𝒜⁢(S)) will necessarily be on-average replace-one stable; this is what I meant by it being the weakest notion. There’s also a more commonly considered but much stronger notion of stability:

Definition 15.3.
222[BE02] defined β as the change from removing the i th element, which implies this one with a factor of 2 difference; [EEP05] extended to random algorithms. This version (without the 2) is called strongly-uniform-replace-one stable by [SSS+10].

A learning algorithm 𝒜 is β⁢(m) -uniformly stable if for all m≥1 ,

supS∈𝒵m,i∈[m]z,z′∈𝒵|𝔼𝒜ℓ⁢(𝒜⁢(S(i←z′)),z)−𝔼𝒜ℓ⁢(𝒜⁢(S),z)|≤β⁢(m).

We say an algorithm is uniformly stable if limm→∞β⁢(m)=0 .

That is, changing one point in any training set gives you a hypothesis that looks almost the same for any test point.

If you know differential privacy, this might seem familiar: it turns out that an (ε,δ) -differentially private algorithm with loss ℓ∈[0,1] is (eε−1+δ) -uniformly stable ([WLF16], Lemma 23).

If 𝒜 is β⁢(m) -uniformly stable, it’s ε⁢(m) -on-average-replace-one stable, just by plugging in the definitions. But the converse is not true. (There are also in-between notions; see [BE02, SSS+10].)

If we do have uniform stability, though, we can get stronger bounds:

Theorem 15.4 ([BE02], basically).

Suppose that ℓ⁢(h,z)∈[a,b] almost surely. Let 𝒜 be β⁢(m) -uniformly stable. Then, with probability at least 1−δ over the choice of training points S∼𝒟m ,

𝔼𝒜[L𝒟⁢(𝒜⁢(S))−LS⁢(𝒜⁢(S))]≤β⁢(m)+(2⁢m⁢β⁢(m)+b−a)⁢12⁢m⁢log⁡1δ.

The best case for this bound is when β⁢(m)=𝒪⁡(1/m) , in which case you get a usual 𝒪⁡(1/m) rate. That turns out to be often the case.

Proof.

We’ll apply McDiarmid’s inequality (theorem 5.6) to the function f⁢(S)=𝔼𝒜[L𝒟⁢(𝒜⁢(S))−LS⁢(𝒜⁢(S))] .

Since β⁢(m) -uniformly stable algorithms are ε⁢(m) -on-average-replace-one stable, proposition 15.1 implies that 𝔼Sf⁢(S)≤β⁢(m) .

For brevity, write h^S for 𝒜⁢(S) , and Si for S(i←z′) . Then we have directly that

|𝔼𝒜L𝒟⁢(h^Si)−𝔼𝒜L𝒟⁢(h^S)|≤𝔼z∼𝒟|𝔼𝒜ℓ⁢(h^Si,z)−𝔼𝒜ℓ⁢(h^S,z)|≤β⁢(m).

LS is slightly more complicated, since one evaluation point changes too:

|𝔼𝒜LSi⁢(h^Si)−𝔼𝒜LS⁢(h^S)| ≤1m⁢∑j≠i|𝔼𝒜ℓ⁢(h^Si,zj)−𝔼𝒜ℓ⁢(h^S,zj)|+1m⁢|𝔼𝒜ℓ⁢(h^Si,z′)−𝔼𝒜ℓ⁢(h^S,zi)|
≤1m⁢∑j≠iβ⁢(m)+1m⁢(b−a)=m−1m⁢β⁢(m)+b−am
≤β⁢(m)+b−am.

Thus f satisfies the bounded differences condition of McDiarmid with ci=2⁢β⁢(m)+b−am . Combining with 𝔼Sf⁢(S)≤β⁢(m) gives the desired result. ∎

In fact, even stronger rates have been shown recently, with more complex techniques; 333I don’t know whether their results hold for random 𝒜 or not. [BKZ20] showed for deterministic 𝒜 that, with probability at least 1−δ over the choice of S ,

L𝒟⁢(𝒜⁢(S))−LS⁢(𝒜⁢(S))≤const⁢(β⁢(m)⁢log⁡(m)⁢log⁡1δ+b−am⁢log⁡1δ) (15.1)

by simplifying and improving techniques of [FV18, FV19] inspired by techniques from differential privacy. This shows a 𝒪~p⁢(1/m) rate as long as β⁢(m)=𝒪~⁢(1/m) , much weaker than the 𝒪~⁢(1/m) required by theorem 15.4.

15.2 Convex RLM

Recall regularized loss minimization (RLM), and suppose h↦ℓ⁢(h,z) is convex for each z , 444If it’s strongly convex with some different m , just scale it and inversely scale λ . and R⁢(h) is 1-strongly convex. Then fS⁢(h)=LS⁢(h)+λ⁢R⁢(h) , the sum of a convex function and a λ -strongly convex function, is λ -strongly convex. Let 𝒜⁢(S) denote arg⁢minh∈ℋ⁡fS⁢(h) ; since fS is strongly convex, it has a unique minimizer.

Now, notice that for any h∈ℋ , we have that

fS⁢(h)=fS(i←z′)⁢(h)−1m⁢ℓ⁢(h,z′)+1m⁢ℓ⁢(h,zi).

Thus for any h,g∈ℋ ,

fS⁢(h)−fS⁢(g)=fS(i←z′)⁢(h)−fS(i←z′)⁢(g)+ℓ⁢(h,zi)−ℓ⁢(g,zi)m+ℓ⁢(g,z′)−ℓ⁢(h,z′)m.

Plugging in h=h^i=𝒜⁢(S(i←z′)) and g=h^=𝒜⁢(S) , since h^i minimizes fS(i←z′) , we get that

fS⁢(h^i)−fS⁢(h^)≤ℓ⁢(h^i,zi)−ℓ⁢(h^,zi)m+ℓ⁢(h^,z′)−ℓ⁢(h^i,z′)m.

Noting also that ∇fS⁢(h^)=0 , proposition C.3 implies that fS⁢(h^i)−fS⁢(h^)≥12⁢λ⁢∥h^i−h^∥2 . Thus we’ve shown that

λ2⁢∥h^i−h^∥2≤ℓ⁢(h^i,zi)−ℓ⁢(h^,zi)m+ℓ⁢(h^,z′)−ℓ⁢(h^i,z′)m. (15.2)

15.2.1 Lipschitz loss

If we further assume that h↦ℓ⁢(h,z) is ρ -Lipschitz for each z , i.e.  |ℓ⁢(h,z)−ℓ⁢(h′,z)|≤ρ⁢∥h−h′∥ for all z , then (15.2) yields that

λ2⁢∥h^i−h^∥2≤2⁢ρm⁢∥h^i−h^∥,

and hence

∥h^i−h^∥≤4⁢ρλ⁢m.

Using the Lipschitz property again,

|ℓ⁢(h^i,z)−ℓ⁢(h^,z)|≤ρ⁢∥h^i−h^∥≤4⁢ρ2λ⁢m

for any z , and so we’ve shown 4⁢ρ2λ⁢m -uniform stability. Plugging into theorem 15.4, we’ve shown the following result.

Proposition 15.5.

Suppose that h↦ℓ⁢(h,z) is ρ -Lipschitz and convex for each z∈𝒵 . Let h↦λ⁢R⁢(h) be λ -strongly convex. Then the RLM algorithm 𝒜 of (RLM) is 4⁢ρ2/(λ⁢m) -uniformly stable, and hence

𝔼S∼𝒟m[L𝒟⁢(𝒜⁢(S))−LS⁢(𝒜⁢(S))]≤4⁢ρ2λ⁢m.

If we further have that ℓ⁢(h,z)∈[a,b] for all h and 𝒟 -almost all z , (RLM) satisfies that, with probability at least 1−δ over the choice of S∼𝒟m ,

L𝒟⁢(𝒜⁢(S))−LS⁢(𝒜⁢(S))≤4⁢ρ2λ⁢m+(8⁢ρ2λ+b−a)⁢12⁢m⁢log⁡1δ.

15.2.2 Smooth, nonnegative loss

It’s possible, though messier, to show a similar result for nonnegative β -smooth functions (those with β -Lipschitz gradients, as in definition 11.1): in the end, if you also assume that λ≥2⁢β/m , you get (see [SB14, Section 13.3.2]) that

𝔼S,z′[LS⁢(𝒜⁢(S(i←z′)))−LS⁢(𝒜⁢(S))]≤48⁢βλ⁢m⁢𝔼S[LS⁢(𝒜⁢(S))].

If R is nonnegative and there is some h0 with R⁢(h0)=0 , e.g. the zero predictor when R⁢(h)=∥h∥2 , and we also have that ℓ⁢(h0,z)≤b , say because the loss is always less than b , then we know that

LS⁢(𝒜⁢(S))≤LS⁢(𝒜⁢(S))+λ⁢R⁢(𝒜⁢(S))≤LS⁢(h0)+λ⁢R⁢(h0)≤b,

in which case we can upper-bound 𝔼SLS⁢(𝒜⁢(S)) by b .

15.3 Fitting-Stability Trade-Off

Proposition 15.5 shows that L𝒟⁢(𝒜⁢(S)) is closer to LS⁢(𝒜⁢(S)) as λ grows. But LS⁢(𝒜⁢(S)) will also get worse for bigger λ , since 𝒜 cares more and more about having “simpler” h than minimizing LS . How can we find the best λ to trade off between them?

For any fixed h∗ , if R is nonnegative and 1 -strongly convex, we have that

LS⁢(𝒜⁢(S))≤LS⁢(𝒜⁢(S))+λ⁢R⁢(h)≤LS⁢(h∗)+λ⁢R⁢(h∗),

and hence

𝔼SLS⁢(𝒜⁢(S))≤L𝒟⁢(h∗)+λ⁢R⁢(h∗). (15.3)

15.3.1 Expected loss

So, using (15.3) and propositions 15.1 and 15.5,

𝔼SL𝒟⁢(𝒜⁢(S)) ≤L𝒟⁢(h∗)+λ⁢R⁢(h∗)+𝔼S[L𝒟⁢(𝒜⁢(S))−LS⁢(𝒜⁢(S))]
≤L𝒟⁢(h∗)+λ⁢R⁢(h∗)+4⁢ρ2λ⁢m (15.4)

if the loss is convex and ρ -Lipschitz, and R is nonnegative and 1 -strongly convex.

We now have two routes we can take from this bound.

Choosing λ

Because our canonical regularizer is R⁢(h)=12⁢∥h∥2 , let’s compare our result to any h∗ satisfying R⁢(h∗)≤12⁢B2 . We then have

𝔼SL𝒟⁢(𝒜⁢(S))≤L𝒟⁢(h∗)+12⁢λ⁢B2+4⁢ρ2λ⁢m. (15.5)

Using that α⁢x+β/x is minimized at x=β/α with value 2⁢α⁢β , we can minimize this bound by picking λ=ρB⁢8m to get

𝔼SL𝒟⁢(𝒜⁢(S))≤infh∗:R⁢(h∗)≤12⁢B2L𝒟⁢(h∗)+ρ⁢B⁢8m.
Definition 15.6.

A learning problem is convex, ρ -Lipschitz, B -bounded 555 The class of problems is also sometimes described in terms of Bregman divergences; see e.g. Chapter 14 of [MRT18]. if the hypothesis set ℋ is convex, bounded as R⁢(h)≤12⁢B2 for all h∈ℋ for some strongly convex function R , and the loss functions h↦ℓ⁢(h,z) are convex and ρ -Lipschitz for each z∈𝒵 .

Regularized loss minimization can therefore learn (in the sense of expected loss) any convex-Lipschitz-bounded learning problem. (Section 12.2.1 of [SB14] gives examples of problems which are not learnable if they’re convex but not Lipschitz and/or not bounded.)

You can do a similar thing for the case where the loss is nonnegative and smooth instead of Lipschitz ([SB14], Corollaries 13.10 and 13.11).

Fixing λ

Instead of fixing some B and picking λ accordingly, we can instead ask: what happens if we run the algorithm with any particular choice of λ ? We minimized (15.5) in terms of λ , but it’s equivalent to take λ as given and minimize the bound in terms of B , in which case we find B=ρλ⁢8m and

𝔼SL𝒟⁢(𝒜⁢(S))≤infh∗:R⁢(h∗)≤12⁢(ρλ⁢8m)2L𝒟⁢(h∗)+8⁢ρ2λ⁢m.

This is exactly the same analysis, but tells us what happens with different choices of λ : for instance, if we pick a constant λ as m grows, then we only compete with simpler and simpler hypotheses as we see more data (not ideal).

We need 1λ⁢m→0 for the second term to go to zero, i.e. we need λ=ω⁢(1/m) . If we also want to eventually compete with any possible predictor, we need 1λ⁢m→∞ , i.e.  λ=o⁢(1/m) . Thus, consider picking λ∝m−γ for any γ∈(1/2,1) : the second term becomes 𝒪⁡(mγ−1) .

Note that this means boundedness isn’t actually required for learnability: convexity and Lipschitzness of the loss is enough. With boundedness, however, we know that infh⁣∗⁣:R⁢(h∗)⁣≤12⁢(ρλ⁢8m)2L𝒟⁢(h∗) will become exactly infh∗∈ℋL𝒟⁢(h∗) for m bigger than some threshold. Without boundedness, it might be that infh∗∈ℋL𝒟⁢(h∗) is not actually achieved, only approached as R⁢(h∗)→∞ ; this is actually the case for logistic regression of separable data. To get a final bound, then, we would need to know the rate at which infh⁣∗⁣:R⁢(h∗)⁣≤12⁢(ρλ⁢8m)2L𝒟⁢(h∗) approaches its asymptote as m grows.

15.3.2 High-probability bound

To get high-probability bounds, also assume that ℓ∈[a,b] .

We showed in the proof of theorem 15.4 that L𝒟⁢(𝒜⁢(S)) satisfies bounded differences with ci=β⁢(m) . We then have that L𝒟⁢(𝒜⁢(S)) is close to 𝔼SL𝒟⁢(𝒜⁢(S)) , which we just upper-bounded; we don’t actually need to apply theorem 15.4 directly, and doing so wouldn’t be any tighter. This tells us that

L𝒟⁢(𝒜⁢(S))≤𝔼SL𝒟⁢(𝒜⁢(S))+4⁢ρ2λ⁢m⁢m2⁢log⁡1δ,

and plugging in (15.5) gives for any fixed h∗ , it holds with probability at least 1−δ that

L𝒟⁢(𝒜⁢(S))≤L𝒟⁢(h∗)+λ⁢R⁢(h∗)+4⁢ρ2λ⁢m+4⁢ρ2λ⁢m⁢12⁢log⁡1δ. (15.6)

We can see that the choice λ∝1/m , which was optimal in the average-case analysis of section 15.3.1, will now give us a constant upper bound. That’s no good. The problematic term is β⁢(m)⁢m , the same as in theorem 15.4, but using λ∝1/m means that β⁢(m)=𝒪⁡(1λ⁢m) becomes 𝒪⁡(1/m) .

We’ll thus need a larger λ . Assuming R⁢(h∗)≤12⁢B2 , we can minimize (15.6) when

λ=2B2⋅4⁢ρ2⁢(1m+12⁢m⁢log⁡1δ)=ρB⁢8⁢(1m+12⁢m⁢log⁡1δ),

giving a bound of

L𝒟⁢(𝒜⁢(S))−L𝒟⁢(h∗)≤B⁢ρ⁢8⁢(1m+12⁢m⁢log⁡1δ).

Notice that this upper bound on the suboptimality is bigger than B⁢ρ⁢(32m⁢log⁡1δ)1/4 ; that m−1/4 rate is much slower than the m−1/2 rate for the mean!

Using the sharper bound of (15.1) instead gives a much better result:

L𝒟⁢(𝒜⁢(S))−L𝒟⁢(h∗)=𝒪⁡(λ⁢B2+ρ2λ⁢m+ρ2λ⁢m⁢log⁡m⁢log⁡1δ+b−am⁢log⁡1δ).

This upper bound is minimized by λ=Θ⁢(ρB⁢1+log⁡m⁢log⁡1δm)=Θ~⁢(ρB⁢m) , giving

L𝒟⁢(𝒜⁢(S))−L𝒟⁢(h∗)=𝒪⁡(B⁢ρ⁢1+log⁡m⁢log⁡1δm+b−am⁢log⁡1δ)=𝒪~p⁢(max⁡(B⁢ρ,b−a)m).

This is a far more satisfying final bound, and notice that the choice of λ is similar (up to log factors) to the case from section 15.3.1 where we only analyzed the mean.

Either of these analyses shows that convex-Lipschitz-bounded learning problems are also learnable by RLM with high probability.

A similar, but messier, analysis should also work for the case of a nonnegative β -smooth loss.

15.4 More

Other algorithms than RLM are also stable. The theory originated out of analyses of “local learning rules” like k -nearest neighbour, which are on-average-replace-one stable (and “hypothesis stable”) but not uniformly stable. You can also show that (stochastic) gradient descent is uniformly stable for convex problems, and even get some results in non-convex settings ([HRS15, FV19]). And, as mentioned, any differentially private algorithm is automatically uniformly stable (with the randomized variant).

Stability is also very useful for analyzing cross-validation, especially leave-one-out cross-validation, which is discussed by many of the papers here ([BE02, SSS+10]).

[SSS+10] also have thorough accounting of when stability is necessary, or not, to be able to learn different kinds of problems, and [WLF16] a similar accounting of the relationship to privacy.