Online Learning
An online learner can be converted into a PAC learner by running it on T independently sampled examples.
A Decision Before the Answer
Imagine a learner that must decide whether a current instance belongs to one class or another before it knows the correct answer. After making the prediction, the learner receives the true label and can use that information to improve later predictions. This timing pattern is the central idea of online learning: prediction and learning are interwoven instead of being separated into two large phases.
Four Events in Every Round
An online learning run consists of consecutive rounds. In round t, the algorithm has a current hypothesis h_t. It receives an instance, uses h_t to make a prediction, observes the correct label, and then uses that label to support future predictions. These four events occur in order: receive the instance, predict, reveal the label, and update the learner's later behavior.
- The learner receives the current instance.
- The learner predicts before seeing the correct label.
- The correct label is revealed.
- The learner uses the revealed label to support future predictions.
From Test to Training
An example has two roles at different moments of the same round. Before its label is revealed, it tests the learner's current hypothesis because the learner must predict its label without knowing the answer. After the correct label is revealed, that same example can contribute to future learning. This is why online learning repeatedly combines prediction and training within each round.
Tracing one generated round
Follow a single online round in which the learner receives an instance, predicts, and then receives the correct label.
Receive: The learner receives the current instance x_t while its correct label is not yet available.
Predict: The current hypothesis h_t maps the instance to a prediction, such as 0 or 1.
Reveal: The correct label is supplied only after the prediction has been made.
Learn: The revealed label becomes information that can support predictions in later rounds.
The example first tests h_t and then becomes available for future learning.
Building a PAC Learner from the Run
The online-to-PAC conversion runs the online algorithm on T independently sampled examples. Suppose examples come from a distribution D over an instance domain X, and their labels are supplied by a true hypothesis h⋆ in H. At round t, the online algorithm uses h_t to predict the label of the tth example. After all T rounds, the run has produced the sequence h_1 through h_T. The converted PAC learner chooses a uniformly random member h_r of that sequence as its output.
- Draw T examples independently from D.
- Process them in order through the online learner.
- Record the current hypothesis h_t associated with each round.
- Choose an index r uniformly from the T rounds.
- Return h_r as the PAC learner's hypothesis.
Why the Mistake Bound Matters
Assume the online algorithm has a finite mistake bound M_A(H). This bound limits the total number of prediction mistakes the algorithm can make across the online sequence. Because the selected hypothesis h_r comes from that sequence, the total mistakes constrain the average error represented across the hypotheses. The resulting expected risk of the uniformly selected hypothesis is bounded by M_A(H) divided by T.
How T changes the bound
Suppose an online algorithm has a finite mistake bound M_A(H), and it is run for T rounds. What does the conversion guarantee about the selected hypothesis?
Count mistakes: Across the online sequence, the total number of mistakes is limited by M_A(H).
Select a round: Choose one index r uniformly, so every hypothesis h_1 through h_T has the same chance to become the output.
Relate errors to rounds: The expected risk of the selected hypothesis is bounded by the mistake bound divided by the number of rounds.
Increase T: With the mistake bound held fixed, increasing the number of online examples makes the bound M_A(H) / T smaller.
The online learner supplies the numerator through its mistake bound, while the amount of online data supplies the denominator through T.
Choosing a Hypothesis from the Sequence
The converted learner does not invent a separate hypothesis by applying a new selection rule outside the online process. The online run itself creates h_1, h_2, and so on through h_T. A random index r identifies which member is returned. The expected guarantee accounts for both sources of randomness: the independently sampled examples and the random choice of r.
The selection works because the online mistakes are distributed over the sequence of rounds. If the sequence contains only a bounded total number of mistakes, then choosing a member of the sequence uniformly cannot have an uncontrolled expected risk under the conversion's assumptions. The guarantee is therefore an average expected guarantee over the sampled examples and the random index.
Online and PAC Learning Compared
| Feature | Online learning | PAC learning |
|---|---|---|
| Organization | Consecutive rounds that combine prediction and learning | A batch training phase followed by prediction on new examples |
| Current example | The learner predicts before receiving its correct label | The learner first receives training examples before producing the hypothesis used for later evaluation |
| Hypothesis behavior | The current hypothesis can change across rounds | The learner produces a hypothesis from the training batch |
| Conversion connection | Produces h_1 through h_T during the online run | Can use a uniformly selected h_r from that run as the output hypothesis |
In the source's papaya analogy, PAC learning means tasting a group of papayas before predicting the taste of new papayas. Online learning instead requires a prediction about each current papaya before its correct taste is known; after the answer is obtained, that papaya can help with later predictions.
Common Reasoning Mistakes
Treating online learning as a batch training phase followed by a separate prediction phase.
Online learning interweaves prediction and learning across consecutive rounds.
Fix:
Remember the order within each round: instance, prediction, revealed label, and support for future predictions.Assuming the label is available before the online prediction.
The defining timing pattern is that the prediction occurs before the correct label is revealed.
Fix:
Treat the current example as a test example first and as a training example afterward.Selecting a hypothesis that was not produced during the online run.
The described conversion selects a uniformly random h_r from h_1 through h_T.
Fix:
Track the hypotheses created at the rounds and choose one of those members.Ignoring the mistake bound.
The conversion assumes a finite mistake bound M_A(H), which limits total mistakes.
Fix:
Connect the guarantee to both quantities: the mistake bound M_A(H) and the number of rounds T.Thinking that increasing T changes the algorithm's mistake bound.
The source describes M_A(H) as the algorithm's contribution and T as the amount of online data in the bound.
Fix:
Keep the roles separate: M_A(H) limits total mistakes, while T determines how those mistakes affect the expected-risk bound.
Check Your Understanding
Explain the online-to-PAC conversion in your own words. Your explanation should name the source of the T examples, identify the sequence h_1 through h_T, state how h_r is selected, and describe the role of M_A(H) in the expected-risk bound.
Hints
- Start with the order of events in one online round.
- Then explain what the complete run produces.
- Finally connect the finite mistake bound and T to the expected risk.
A learner receives an example, predicts its label, sees the correct label, and uses that information on later examples. Is this schedule closer to online learning or PAC learning? Explain which event establishes your answer.
Hints
- Focus on whether prediction happens before or after the label is known.
- PAC learning separates its batch training phase from later prediction.
Key Takeaways
- Online learning is a sequence of rounds in which the learner receives an instance, predicts, observes the correct label, and uses that label for future predictions.
- The same example is first a test of the current hypothesis and then a source of training information.
- Running an online learner on T independently sampled examples creates hypotheses h_1 through h_T.
- The converted PAC learner chooses a uniformly random h_r from that sequence.
- A finite mistake bound M_A(H) limits total online mistakes, producing an expected-risk bound of M_A(H) divided by T.
Key Takeaways
- Online learning combines prediction and learning within consecutive rounds rather than separating them into batch training and later prediction.
- Each round follows the order: receive an instance, predict, reveal the label, and use the result for future predictions.
- An online run on T independently sampled examples produces h_1 through h_T, from which a uniformly selected h_r becomes the PAC output.
- The finite mistake bound M_A(H) limits total online mistakes and gives the selected hypothesis expected risk bounded by M_A(H) / T.
- The conversion connects the online and PAC views without creating a hypothesis outside the online learner's sequence.