Offline Evaluation of Predictive Models
Offline evaluation measures predictions on a test set collected beforehand and is the first step for a user-facing system.
A Good Score Is Not the Finish Line
Suppose you have built a model that makes predictions, and you want to know whether it is good enough to use. A natural first move is to collect a set of examples ahead of time, hold them back as a test set, and measure how accurately the algorithm predicts on that set. This is what offline evaluation means. It is a useful starting point, but it answers a narrow question: how well does the algorithm perform on data we already have?
What do you think happens?
If a model scores well on a stored test set, does that guarantee it will produce good results once real users interact with it?
Reveal answer
No. A good score on a stored test set may not tell the whole story.
When the algorithm feeds a system people interact with, such as a website that recommends products or ranks search results, changes in what people see can change how they behave. A stored test set cannot capture those behavioral responses.
What an Offline Score Actually Measures
Offline evaluation measures predictions on a test set collected beforehand. The test set is held back from the model during development, so the score reflects performance on examples that were gathered in advance rather than on whatever users do in the moment.
The score answers the question of how well the algorithm performs on data we already have. It does not answer what happens after the algorithm is deployed and starts changing what people see. That gap between stored data and live behavior is the reason offline evaluation is only the first step for a user-facing system.
Where Offline Evaluation Sits in the Sequence
Offline evaluation is the first step in evaluating an algorithm for a user-facing system. It is not the last one. Once an algorithm will change what real users see, the offline results must be followed by evaluation under live conditions. The diagram below shows the order: offline evaluation comes first, online testing follows, and bandit algorithms extend online testing.
Why Live Behavior Can Differ from Stored Data
Online testing evaluates the consequences of an algorithm inside the overall live system. The reason is that changes to what a website shows can alter user behavior in ways that no stored test set would reveal. Changing the recommendations or search results a site presents can drastically change how people behave, and that change can lead to unexpected consequences.
Follow one request through the system to see where this happens. A user makes a request, the model produces a prediction such as a recommendation, the user reacts to what is shown, and the reaction is recorded as a success metric. The model's offline score never sees that final reaction, so the consequences can only be observed by measuring the live flow.
How an A/B Test Runs, Step by Step
An A/B test splits users into groups served different algorithms, records success metrics over a set period, and compares the results in the wild. In many real deployments, algorithm A is a new model and algorithm B is the established system it may replace. The steps follow a fixed order, shown in the diagram below.
- 1Step 1: Divide users into two groups.
- 2Step 2: Serve each group its algorithm for a set period of time.
- 3Step 3: Record the relevant success metrics for both groups throughout that period.
- 4Step 4: Compare the metrics for algorithm A and algorithm B, and choose between the two approaches according to those metrics.
Tracing Six Users Through a Test
The source describes the steps of an A/B test but does not specify how users should be assigned to groups in practice. The following trace is an illustration written for this lesson. It uses a simple invented rule that alternates assignments, and the metric is whether the user clicked (1 for yes, 0 for no). The point is the flow: assign each user to one group, record a metric for each user, then compare the group summaries.
Comparing two groups with six users
Six users arrive in order. Odd-numbered users go to algorithm A and even-numbered users go to algorithm B. Each user's click is recorded as 1 or 0. Which algorithm has the higher average click rate?
- 1Step 1: Assign users to groups
User 1 goes to A, user 2 to B, user 3 to A, user 4 to B, user 5 to A, user 6 to B. Each user lands in exactly one group.
- 2Step 2: Record the metric for each user
User 1 clicked (1), user 2 did not (0), user 3 did not (0), user 4 clicked (1), user 5 clicked (1), user 6 did not (0).
- 3Step 3: Summarize each group
Group A holds users 1, 3, and 5 with clicks 1, 0, 1. The average is 2 out of 3. Group B holds users 2, 4, and 6 with clicks 0, 1, 0. The average is 1 out of 3.
- 4Step 4: Compare the summaries
Algorithm A has the higher average in this trace, so the comparison points toward A. This is a comparison of two averages, not a full decision, as the next section explains.
Algorithm A averaged 2 clicks per 3 users and algorithm B averaged 1 per 3 users in this illustrative trace.
| User | Group | Clicked (1 = yes, 0 = no) |
|---|---|---|
| 1 | A | 1 |
| 2 | B | 0 |
| 3 | A | 0 |
| 4 | B | 1 |
| 5 | A | 1 |
| 6 | B | 0 |
Illustrative trace of six users. The alternating assignment is an invented rule for this lesson.
What a Two-Group Comparison Cannot Tell You
The comparison in the trace above only looks at averages. A real test would also need to consider how long the test ran and whether the difference is large enough to trust. The source material does not go into those details, so this article does not extend the example beyond the comparison itself.
Where Bandit Algorithms Fit
A/B testing is not the only way to run online tests. There are more elaborate mechanisms for online testing that go beyond A/B testing, and bandit algorithms are one such mechanism. They belong to the same family of live evaluation methods, but they are presented as more advanced than a fixed two-group comparison.
This article only introduces bandit algorithms. It does not explain how they decide which users see which algorithm, so questions such as how traffic shares shift as results accumulate are outside its scope. What you can take away is the direction of the progression: offline evaluation, then A/B testing, then bandit algorithms that extend online testing.
Mistakes to Avoid When Reading Evaluation Results
Common mistake Treating a strong offline test score as proof that the model is ready for users
What it looks likeA recommendation model scores well on a stored test set, so it is shipped to all visitors without live testing.
Why it failsOffline evaluation answers how well the algorithm performs on data already collected. Changed recommendations can alter user behavior in ways no stored test set reveals.
Do this insteadFollow offline results with online evaluation under live conditions before relying on the model for a user-facing system.
Common mistake Assuming an A/B test is just a single comparison of two numbers
What it looks likeTwo group averages are compared and the higher one is declared the winner immediately.
Why it failsThe source notes that a real test also considers how long it ran and whether the difference is large enough to trust, and this article does not cover those details.
Do this insteadTreat the averages as one input, and check the test duration and the size of the difference before deciding.
Common mistake Assuming the two groups are directly comparable without checking
Why it failsA difference between groups can mislead when conditions or user mixes differ between them.
Common mistake Believing bandit algorithms are a replacement for offline evaluation
Why it failsThe source places bandits as an extension of online testing, which itself comes after offline evaluation in the sequence.
Practice: Trace the Test Again
Use the six-user trace from earlier. Suppose user 6 clicks, so that user 6's metric is 1 instead of 0. Keeping the same alternating assignment, what are the average click rates for algorithms A and B, and which algorithm does the comparison now favor?
Hints
- Group B holds users 2, 4, and 6. Recompute its clicks with user 6 now recorded as 1.
- Group A is unchanged, so its average is still 2 out of 3.
- Compare the two averages once group B is recomputed. A tie means the simple comparison does not favor either algorithm.
Key Takeaways
- Offline evaluation measures predictions on a test set collected beforehand, and it is only the first step for a user-facing system.
- Online testing evaluates the consequences of an algorithm inside the live system, because changed recommendations or search results can alter user behavior.
- An A/B test divides users into groups served different algorithms, records success metrics over a set period, and compares the results.
- Comparing two group averages can mislead when groups differ, and bandit algorithms extend online testing beyond a fixed two-group comparison, though this article only introduces them.