Online Learning and Regret Bounds
An online learner updates itself one observation at a time, forever, rather than training once on a fixed batch — and instead of asking "how accurate is it," the theory asks "how much worse did it do, in total, than the best fixed strategy in hindsight."
Prerequisites: Gradient Descent, Stochastic Gradient Descent
Most machine-learning training happens once, on a fixed batch of historical data, and then the model is frozen and deployed. Online learning instead updates the model after every single new observation, forever — a market-making quote model that revises itself after every fill, or a spread-prediction model that adjusts after every tick. There's no "training set" and "test set" in the usual sense; there's just a stream, and the question becomes how to measure whether the ongoing stream of decisions was any good.
Online learning theory scores an algorithm by its regret: the total gap between the loss it actually accumulated and the loss the single best fixed strategy, chosen with hindsight, would have accumulated over that same stream. A good online algorithm has regret that grows slower than the number of rounds — its average per-round disadvantage shrinks toward zero even though it never got to see the future.
What "regret" actually measures
After rounds, define regret as , where is the loss suffered in round , is the parameter the algorithm actually used at round , and ranges over every fixed parameter choice you could have committed to from the start. In words: add up how much loss the algorithm actually incurred, subtract how much loss the single best strategy in hindsight would have incurred over that entire stretch, and the difference is regret. A standard result for online gradient descent on convex losses is — regret grows, but slower than itself, so average regret per round, , shrinks toward zero as more rounds accumulate.
Worked example
A spread-quoting model updates its bid-ask width after every trade using online gradient descent, and over trades its regret bound guarantees for some constant tied to the loss's smoothness. Suppose , so — the model's cumulative loss across all 10,000 trades is at most 200 loss-units worse than the single best fixed spread width chosen with full hindsight of every trade that would occur. That may sound unimpressive in absolute terms, but per-trade it's an average disadvantage of at most loss-units — and if the stream ran to 1,000,000 trades instead, the bound only grows to larger (), while the number of trades grew , so the average disadvantage per trade falls to : the online learner is closing in on hindsight-optimal performance as it sees more data, without ever needing to re-solve from scratch.
What this means in practice
Online learning fits any setting where the environment keeps changing and a batch-trained model would go stale — adaptive market-making, real-time fraud scoring, order-routing that adjusts to shifting venue liquidity. Regret bounds are a guarantee about the worst case over the sequence actually observed, not a promise about future accuracy in some absolute sense, and they typically assume the loss functions are convex; regret bounds for the non-convex losses that show up with neural networks are much weaker or unavailable.
A sublinear regret bound compares only against a single fixed strategy in hindsight — it says nothing about how a strategy that itself changes over time (like a strategy that adapts to a regime shift) would have done. Beating "the best constant spread over 10,000 trades" is a much lower bar than beating "the best possible adaptive strategy," so don't over-read a good regret bound as proof the algorithm is close to optimal in any absolute sense.
Practice in interviews
Further reading
- Cesa-Bianchi & Lugosi, Prediction, Learning, and Games (2006)
- Hazan, Introduction to Online Convex Optimization (2016)