Search

Search papers and lessons

No-Regret Learning

Level 4 · 12 min read

A no-regret learner makes a sequence of choices whose total loss ends up close to that of the best single fixed choice in hindsight, even when the losses are chosen adversarially.

On this page

  • Colour = topic mix
  • Calculus
  • Probability
  • Linear algebra
  • Losses & regularization
  • Optimizers
  • Reinforcement learning
  • Sign in to see your progress

TL;DR

In online learning you make a choice each round, then see how well it did. A no-regret learner is one whose total loss, over many rounds, ends up close to the total loss of the single best fixed choice you could have made in hindsight. The gap between the two is called regret. The guarantee holds even when the losses are picked by an adversary, so no assumption about the world's pattern is needed. The gap grows more slowly than the number of rounds, so the average regret goes to zero.

Where you'll see it: in online advertising and bidding, in the analysis of imitation learning (the DAgger algorithm), in the bandit algorithms behind exploration, and in the proof that two learners playing a zero-sum game converge to its minimax strategies.

Intuition

Choosing before you know

Suppose each morning you pick one of several routes to work. You do not know the traffic in advance. After the commute you learn how long each route would have taken. The next day you choose again, using everything you have seen so far.

No route is best every day, and an adversary could make your favourite route the worst one tomorrow. So the question is not "did I always pick the best route?", which may be impossible. It is "how much worse was I than the single route I would have been best off sticking to, over the whole period?" That comparison is regret.

Why the best fixed choice is the right yardstick

Regret compares you to a fixed choice that you could have made knowing all the losses ahead of time. It is a demanding standard because the comparison has hindsight, yet it is achievable. A learner who reacts to each loss with a small, careful adjustment can keep up with the best fixed strategy without knowing in advance which one that is.

The key quantity is the average regret, the total regret divided by the number of rounds. If it goes to zero, the learner's average performance matches the best fixed choice in the long run, whatever the sequence of losses turned out to be.

flowchart LR
  A[Learner picks an action x_t] --> B[Environment reveals loss for x_t]
  B --> C[Learner updates its strategy]
  C --> A
  B --> D[Regret compares total loss with the best fixed action in hindsight]
2040608010000.20.40.60.81number of rounds Taverage regret per round
  • average regret bound, D G over the square root of T
A typical no-regret guarantee: total regret grows like the square root of T, so the average regret per round falls like one over the square root of T. It reaches 0.1 after about 100 rounds in this scaled plot.

The math

Setup

The learner works over a convex set K\mathcal{K} of possible actions. In round t=1,2,…,Tt = 1, 2, \dots, T:

  1. The learner picks xt∈K\mathbf{x}_t \in \mathcal{K} without knowing the loss of this round.
  2. The environment reveals a loss function ℓt\ell_t, and the learner pays ℓt(xt)\ell_t(\mathbf{x}_t).

The environment may be adversarial: ℓt\ell_t can depend on the learner's past choices, but the learner does not know it in advance.

Definition: Regret

After TT rounds, the regret of a sequence of choices x1,…,xT\mathbf{x}_1, \dots, \mathbf{x}_T against a fixed action u∈K\mathbf{u} \in \mathcal{K} is

RT(u)=∑t=1Tℓt(xt)−∑t=1Tℓt(u).R_T(\mathbf{u}) = \sum_{t=1}^{T} \ell_t(\mathbf{x}_t) - \sum_{t=1}^{T} \ell_t(\mathbf{u}).

The worst-case regret is RT=max⁡u∈KRT(u)R_T = \max_{\mathbf{u} \in \mathcal{K}} R_T(\mathbf{u}). The learner is no-regret if RT/T→0R_T / T \to 0 as TT grows, for every sequence of losses.

Here ∑tℓt(u)\sum_t \ell_t(\mathbf{u}) is the total loss the fixed action u\mathbf{u} would have paid. The maximum over u\mathbf{u} picks the best fixed action in hindsight. Regret is zero if the learner matched it, and positive if it did worse.

Online gradient descent

The standard no-regret algorithm for convex losses is online gradient descent (Zinkevich, 2003). Let gt\mathbf{g}_t be a gradient of ℓt\ell_t at xt\mathbf{x}_t. Update with the same rule as Gradient Descent, then project back into the set:

xt+1=ΠK ⁣(xt−ηtgt),\mathbf{x}_{t+1} = \Pi_{\mathcal{K}}\!\left(\mathbf{x}_t - \eta_t \mathbf{g}_t\right),

where ΠK(y)\Pi_{\mathcal{K}}(\mathbf{y}) is the point of K\mathcal{K} closest to y\mathbf{y}, and ηt>0\eta_t \gt 0 is the step size. Projection is needed because the step can leave the set. Projecting onto a convex set never moves you farther from any point of the set, which is what the proof uses.

The regret bound

Assume the losses are convex, the set has diameter at most DD (any two points are within DD of each other), and the gradients have length at most GG. With the constant step η\eta, the regret against any u\mathbf{u} satisfies

RT(u)≤∥x1−u∥22η+ηG2T2≤D22η+ηG2T2.R_T(\mathbf{u}) \le \frac{\|\mathbf{x}_1 - \mathbf{u}\|^2}{2\eta} + \frac{\eta G^2 T}{2} \le \frac{D^2}{2\eta} + \frac{\eta G^2 T}{2}.

The proof uses two facts. First, convexity gives ℓt(xt)−ℓt(u)≤gt⋅(xt−u)\ell_t(\mathbf{x}_t) - \ell_t(\mathbf{u}) \le \mathbf{g}_t \cdot (\mathbf{x}_t - \mathbf{u}). Second, the squared distance to u\mathbf{u} shrinks by at least 2η gt⋅(xt−u)2\eta\, \mathbf{g}_t \cdot (\mathbf{x}_t - \mathbf{u}) each round, minus a term of size η2G2\eta^2 G^2. Adding the rounds telescopes the distances and leaves the bound.

Choosing η=D/(GT)\eta = D / (G\sqrt{T}) balances the two terms and gives

RT≤DGT.R_T \le D G \sqrt{T}.

So the total regret grows like T\sqrt{T}, and the average regret RT/T≤DG/TR_T / T \le DG / \sqrt{T} goes to zero. This is the defining property of a no-regret algorithm.

Hedge: no-regret over a finite set of experts

Many problems have a finite list of options, called experts. Let there be NN experts, and let each round the environment reveal a loss ℓt(i)∈[0,1]\ell_t(i) \in [0, 1] for each expert ii. The Hedge algorithm (Freund and Schapire, 1997) keeps a weight wt(i)w_t(i) for each expert, starts them at 1, and plays expert ii with probability

pt(i)=wt(i)∑jwt(j),wt+1(i)=wt(i) e−η ℓt(i).p_t(i) = \frac{w_t(i)}{\sum_j w_t(j)}, \qquad w_{t+1}(i) = w_t(i)\, e^{-\eta\, \ell_t(i)}.

The play probabilities are a Softmax over the cumulative negative losses. Experts that did well gain weight exponentially fast. For losses in [0,1][0, 1] and a suitable η\eta, the expected regret against the best expert is at most about Tln⁡N\sqrt{T \ln N}, which is again sublinear in TT.

Worked examples

Example
Online gradient descent on four rounds of linear losses

The action set is K=[0,1]\mathcal{K} = [0, 1]. Each round the loss is ℓt(x)=ct x\ell_t(x) = c_t\, x, so gt=ct\mathbf{g}_t = c_t. Here D=1D = 1 and G=1G = 1. Use the constant step η=0.25\eta = 0.25, start at x1=0.5x_1 = 0.5, and let the losses be c=(+1,−1,+1,−1)c = (+1, -1, +1, -1).

  1. Round 1: play x1=0.5x_1 = 0.5 and pay 1×0.5=0.51 \times 0.5 = 0.5. Update x2=Π(0.5−0.25×1)=0.25x_2 = \Pi(0.5 - 0.25 \times 1) = 0.25.
  2. Round 2: play x2=0.25x_2 = 0.25 and pay −1×0.25=−0.25-1 \times 0.25 = -0.25. Update x3=Π(0.25+0.25)=0.5x_3 = \Pi(0.25 + 0.25) = 0.5.
  3. Round 3: play x3=0.5x_3 = 0.5 and pay 1×0.5=0.51 \times 0.5 = 0.5. Update x4=Π(0.5−0.25)=0.25x_4 = \Pi(0.5 - 0.25) = 0.25.
  4. Round 4: play x4=0.25x_4 = 0.25 and pay −0.25-0.25.
  5. Learner's total loss: 0.5−0.25+0.5−0.25=0.50.5 - 0.25 + 0.5 - 0.25 = 0.5.
  6. Best fixed action: the total loss is (1−1+1−1) u=0(1 - 1 + 1 - 1)\,u = 0 for every uu, so the best is 0.
  7. Regret: 0.5−0=0.50.5 - 0 = 0.5.
  8. Bound check: D22η+ηG2T2=10.5+0.25×42=2+0.5=2.5\frac{D^2}{2\eta} + \frac{\eta G^2 T}{2} = \frac{1}{0.5} + \frac{0.25 \times 4}{2} = 2 + 0.5 = 2.5. The actual regret, 0.50.5, is below the bound.

Interpretation: the algorithm oscillates between 0.25 and 0.5, and each pair of rounds adds 0.25 to the regret. With a constant step, the regret grows linearly in TT, which is consistent with the bound (it is 2+0.125 T2 + 0.125\,T here) but gives no no-regret guarantee. That is why the step must shrink with TT, as the DGTD G \sqrt{T} result requires.

Example
Hedge on two experts with real numbers

There are two experts, A and B, so N=2N = 2. Use η=0.5\eta = 0.5 and the losses below, for T=3T = 3 rounds.

roundloss of Aloss of B
101
201
310
  1. Round 1: weights (1,1)(1, 1), so p=(0.5,0.5)p = (0.5, 0.5). Expected loss 0.5×0+0.5×1=0.50.5 \times 0 + 0.5 \times 1 = 0.5. Update: wB=e−0.5≈0.6065w_B = e^{-0.5} \approx 0.6065, wA=1w_A = 1.
  2. Round 2: pA=1/1.6065≈0.6225p_A = 1 / 1.6065 \approx 0.6225 and pB≈0.3775p_B \approx 0.3775. Expected loss 0.3775×1=0.37750.3775 \times 1 = 0.3775. Update: wB=0.6065×e−0.5≈0.3679w_B = 0.6065 \times e^{-0.5} \approx 0.3679.
  3. Round 3: pA=1/1.3679≈0.7311p_A = 1 / 1.3679 \approx 0.7311 and pB≈0.2689p_B \approx 0.2689. Expected loss 0.7311×1=0.73110.7311 \times 1 = 0.7311.
  4. The learner's total expected loss is 0.5+0.3775+0.7311≈1.60860.5 + 0.3775 + 0.7311 \approx 1.6086.
  5. Totals for the fixed experts: A pays 0+0+1=10 + 0 + 1 = 1, and B pays 1+1+0=21 + 1 + 0 = 2. The best is A with 1.
  6. Regret against the best expert: 1.6086−1=0.60861.6086 - 1 = 0.6086.
  7. Bound check: ln⁡Nη+ηT8=0.69310.5+0.5×38≈1.386+0.188=1.574\frac{\ln N}{\eta} + \frac{\eta T}{8} = \frac{0.6931}{0.5} + \frac{0.5 \times 3}{8} \approx 1.386 + 0.188 = 1.574. The regret 0.60860.6086 is below it.

Interpretation: the algorithm moved weight toward A after the first round, but it still put 38% of its probability on B in round 2 and 27% in round 3, and those hedged bets are where the 0.61 of regret comes from. The total regret is small compared with the number of rounds, which is what the bound promises.

Tradeoffs and failure modes

No-regret is a strong guarantee, and it is easy to misread.

SituationWhat goes wrongBetter choice
Comparing to the best fixed action when the world changes over timeRegret can be tiny while the learner loses badly in absolute termsUse a regret against a sequence of experts, or a tracking-regret bound
Only the chosen action's loss is revealed (a bandit)Full-information algorithms such as Hedge cannot be usedEXP3 and related bandit algorithms, which pay a cost in the bound
The step size needs the horizon TTConstant η\eta tuned for one TT is wrong for anotherUse a step size that shrinks with tt, such as ηt∝1/t\eta_t \propto 1/\sqrt{t}, or the doubling trick
The losses are not convexThe clean bound from projection and convexity does not holdUse a method designed for the case, or a weaker guarantee
Experts are very manyHedge's ln⁡N\ln N term is fine, but the weights become impracticalStructured or sampled expert sets

The guarantee is also about the sequence, not the future. A learner with no regret against a stream of losses can still be exploited by a strategy that anticipates its next move, which is why results about games need the learners to be playing against other no-regret learners, as in the minimax result in the history section.

History

In the 1950s, David Blackwell (1956) developed approachability theory for repeated games, and James Hannan (1957) showed that a player who responds to the history of play can, in the long run, do as well as the best fixed strategy in hindsight. In the 1990s, Nick Littlestone and Manfred Warmuth (1994) introduced the weighted majority algorithm, and Yoav Freund and Robert Schapire (1997) developed Hedge, the same exponential-weight rule, in their analysis of boosting. Freund and Schapire later (1999) showed that when two players both run no-regret learners in a zero-sum game, their time-averaged strategies converge to a minimax equilibrium, which connects the idea to the minimax theorem of von Neumann.

Martin Zinkevich (2003) gave the online gradient descent algorithm and its T\sqrt{T} bound for convex losses, which made the idea usable for continuous action sets. Peter Auer and colleagues (2002) gave EXP3, the no-regret algorithm when only the chosen action's loss is observed, which led to the bandit literature. Stéphane Ross, Geoffrey Gordon and Drew Bagnell (2011) reduced imitation learning to a sequence of supervised learning problems handled by a no-regret learner, the DAgger algorithm.

Check yourself

QuestionRecall: what is the regret of a sequence of choices against a fixed action u\mathbf{u}?Show answer

It is the learner's total loss, ∑tℓt(xt)\sum_t \ell_t(\mathbf{x}_t), minus the total loss ∑tℓt(u)\sum_t \ell_t(\mathbf{u}) that the fixed action u\mathbf{u} would have paid. A positive value means the learner did worse than u\mathbf{u} would have.

QuestionComputation: with η=0.5\eta = 0.5, K=[0,1]\mathcal{K} = [0,1] and G=1G = 1, the bound for online gradient descent is D22η+ηG2T2\frac{D^2}{2\eta} + \frac{\eta G^2 T}{2}. What is the bound after T=16T = 16 rounds, and what is the average regret bound per round?Show answer

Here D=1D = 1, so 12×0.5+0.5×162=1+4=5\frac{1}{2 \times 0.5} + \frac{0.5 \times 16}{2} = 1 + 4 = 5. The average per round is 5/16≈0.315 / 16 \approx 0.31. This is above the optimal-step value DG/T=0.25DG/\sqrt{T} = 0.25, because η=0.5\eta = 0.5 is not the optimal step for T=16T = 16, which is D/(GT)=0.25D / (G \sqrt{T}) = 0.25.

QuestionWhy: why does online gradient descent project back onto K\mathcal{K} after each step, and why does projection not hurt the proof?Show answer

A gradient step can leave the action set, and the learner must play inside it. Projection moves the point to the nearest point of the set. For a convex set and any point u\mathbf{u} in the set, projection never increases the distance to u\mathbf{u}, so the distance argument still holds after projecting. That property is exactly what the telescoping step in the proof needs.

QuestionApplied: a bidding system must choose one of several bid levels each auction, and only learns the revenue of the bid it actually placed. Which family of algorithms fits, and what does the regret bound cost compared with seeing every bid's revenue?Show answer

It is a bandit problem, because only the chosen action's outcome is observed. An algorithm such as EXP3 is the no-regret choice. Its regret bound is worse than the full-information bound, of order TKln⁡K\sqrt{T K \ln K} for KK bid levels instead of order Tln⁡K\sqrt{T \ln K}, because the learner must explore to learn the other bids' revenues.

Sources