Concepts / Offline Evaluation of Machine Learning Models

Offline Evaluation of Machine Learning Models

Offline evaluation judges an algorithm on a test set collected beforehand and is the first step, but for user-facing systems it is not the last.

  • Programming

A Model That Looks Ready

Imagine a recommendation model that scores very well on a carefully prepared set of examples. Its predictions look accurate, its numbers look strong, and it seems ready to ship. The question is what happens next. Once real people start seeing its recommendations on a live website, their behavior may change in ways the test set never captured. This article explains how teams evaluate an algorithm once it is part of a working product, where people react to what it shows them.

What do you think happens?

A recommendation model scores very well offline. What do you expect once real visitors start seeing its recommendations?

  • Visitor behavior will match the test set exactly

  • Visitor behavior may change in ways the test set never captured

  • The live results will always equal the offline score

Reveal answer
Answer:

Visitor behavior may change in ways the test set never captured.

Changing what users see can change how they behave. A stored test set cannot show how people will respond once the algorithm's output is in front of them, so a strong offline score does not guarantee a strong live result.

Offline Evaluation as the First Step

Offline evaluation is where most evaluation starts. It judges an algorithm on a test set collected beforehand. Nothing about this step involves real users reacting to the algorithm. The test set is fixed, so results can be reproduced and candidate models can be compared with one another without putting anything in front of customers.

  1. 1
    Gather examples in advance.
  2. 2
    Hold some of the examples back to form the test set.
  3. 3
    Run the algorithm on the held-back examples.
  4. 4
    Measure how well its predictions match what was expected.

For a user-facing machine learning system, however, offline evaluation is only the first step. It tells you how the algorithm performs on past data. It does not tell you what happens when the algorithm's output is shown to people and they respond to it. The live test comes after the offline stage, as the next step in the same progression.

Stored examplesOffline evaluationHeld-back test setOnline A/B testReal users, algorithms Aand BLive success metricsRecorded over a set periodSelection decisionscored againstfollowed byrecordsinforms
Offline evaluation comes first and works from stored examples. The live A/B test follows it, and the decision is made from live success metrics rather than from the stored test set alone.

Why Offline Numbers Stop Short

The reason offline evaluation is not enough is that changing what users see can change how they behave. Altering the recommendations or search results a website shows can have a large effect on user activity, and that effect may be hard to predict from offline numbers. Online testing, also called live testing, exists to evaluate these consequences inside the real-world system.

AspectOffline evaluationOnline testing
Data sourceStored examples collected beforehandReal users interacting with the system
What it revealsHow predictions match what was expectedWhat follows from the algorithm being in place
ReproducibilityFixed test set, so results can be reproducedMeasured over a set period of live use
Customer exposureNothing is shown to customersReal customers see the algorithm's output

Offline evaluation and online testing answer different questions.

What Online Testing Is Designed to Catch

Online testing is built to surface unexpected consequences before they affect everyone. The source describes these as effects that appear only when real people interact with the system. Offline numbers can miss them because the stored test set never contains the feedback loop that a live product creates.

  • Shifts in user activity that offline numbers did not predict
  • Effects that are hard to foresee from a stored test set
  • Behavior in the wild that the test set never captured
  • Large changes in how people use the service after the algorithm's output is shown to them

Splitting Users Into Two Groups

Most user-facing services use A/B testing to protect against surprises. In an A/B test, a selected portion of users is served the website or service running algorithm A, while the remaining users are served the version running algorithm B. Neither group knows which one it belongs to. Tracing a single arriving user through this process shows how the split works.

  1. 1
    A user arrives at the service.
  2. 2
    The system decides whether this user falls in the selected portion.
  3. 3
    A user in the selected portion is served algorithm A.
  4. 4
    A user in the remaining portion is served algorithm B.
  5. 5
    Relevant success metrics are recorded for both groups over a set period of time.
  6. 6
    The two groups are compared and the algorithm is selected from the results.
Incoming userIn selected portion?Group AServed algorithm ASuccess metricsGroup ACompare the twogroupsGroup BServed algorithm BSuccess metricsGroup Bassignedyesnooutcomes loggedoutcomes loggedover a set periodover a set period
When a user arrives, the system decides which group they land in. Each group sees one algorithm, and the success metrics from both groups flow into a single comparison.

Comparing the Two Groups

A common arrangement is for algorithm A to be a new model and algorithm B to be the established system. The established system acts as the baseline. The new model has to show better metrics in live use before it is selected. This is the practical payoff of testing in the wild: you learn how real users respond, rather than relying only on the stored test set.

Worked example

Reading a Live Comparison

A team tests a new recommendation model against the established system. Over one week, visitors are split between the two. The team wants to know whether to select the new model.

  1. 1
    Identify the roles

    The new model is algorithm A and the established system is algorithm B, which serves as the baseline.

  2. 2
    Confirm the split was made before results

    Visitors were divided into the two groups while the test ran, and neither group knew which algorithm it was seeing.

  3. 3
    Read the success metrics for both groups

    Metrics for group A and group B are recorded over the same set period so they can be compared directly.

  4. 4
    Apply the selection rule

    The new model is selected only if its live metrics are better than the baseline's.

Result

The decision rests on live metrics compared against the baseline, not on the offline score alone.

Mistakes Teams Make With Live Tests

  • Common mistake

    Treating a strong offline score as proof that an algorithm is ready to ship

    What it looks like

    A model scores very well on the held-back test set and is released without a live test.

    Why it fails

    The offline score shows performance on past data and says nothing about how people respond to the output.

    Do this instead

    Use offline evaluation as the first step, then check consequences through online testing.

  • Common mistake

    Forgetting that the established system is the baseline

    What it looks like

    The new model's live metrics are reported without comparing them to the group still running the established system.

    Why it fails

    Without the baseline, there is nothing to show that the new model performs better in live use.

    Do this instead

    Compare the new model's live metrics against the established system's metrics over the same period.

  • Common mistake

    Assuming a live test reveals users' identity or group membership to them

    What it looks like

    Users are told which algorithm they are seeing during the test.

    Why it fails

    In the A/B arrangement described in the source, neither group knows which one it belongs to.

    Do this instead

    Keep group membership hidden from users while recording outcomes for each group.

  • Common mistake

    Expecting an A/B test to be complete in a single moment rather than over a set period of time

Where Bandit Algorithms Fit

A/B testing is not the only way to test online. There are more elaborate mechanisms for online testing that go beyond A/B testing, and bandit algorithms are one such mechanism. The source material treats them as a more advanced topic and recommends a dedicated introduction for readers who want the details. This article only places them within the progression.

Evaluating analgorithmOffline evaluationA/B testingBandit algorithmsOnline testingLive testingMore elaborate onlinemethodsstandard formgoes beyond
Offline evaluation and online testing are two branches of evaluation. A/B testing is the standard form of online comparison, and bandit algorithms belong to the more elaborate online methods that build on it.

Trace a Recommendation Test

EASY

A team runs an A/B test in which a selected portion of visitors sees a new recommendation model (algorithm A) and the rest see the established system (algorithm B). Trace one visitor from arrival to decision. Name the group that visitor lands in, the algorithm they see, what gets recorded, and what the team compares before selecting a model.

Hints
  • Start with the split: the visitor either falls in the selected portion or does not.
  • Remember that neither group knows which algorithm it belongs to.
  • Think about which group serves as the baseline and what must be shown in live use before the new model is selected.

Key Takeaways

  • Offline evaluation judges an algorithm on a test set collected beforehand. It is the first step, but for user-facing systems it is not the last.
  • Changing what users see can change how they behave, so online testing evaluates the consequences of an algorithm inside the real-world system.
  • In an A/B test, a selected portion of users is served algorithm A and the rest are served algorithm B, and success metrics are recorded for both groups over a set period before the two are compared.
  • A/B testing is the standard form of online comparison, and bandit algorithms are a more elaborate online testing mechanism that goes beyond it.

Related concepts

More concepts starting with O