Concepts / Understanding Offline and Online Evaluation

Understanding Offline and Online Evaluation

Offline evaluation measures predictions on data collected in advance. Online testing measures what happens when the algorithm is actually in front of users.

  • Programming

A Model That Looks Good on Paper

Suppose you have built a recommendation model and it performs well on a test set that you collected before deployment. That result is encouraging, but it answers only part of the question. A model that scores well on past data may still change what real people do once it is placed in front of them. This article looks at the next step in evaluation, the one that happens after offline checks are done, and at one of the most common tools used to carry it out.

Keep one question in mind as you read: when an algorithm changes what a user sees, what evidence would tell you whether that change actually helped the people using the system?

What Offline Evaluation Can and Cannot Tell You

Offline evaluation is a necessary starting point. It is cheap to repeat, it does not expose real users to an unfinished system, and it lets you compare candidate models on identical inputs. For a user-facing machine learning system, however, it is only the first step in evaluating an algorithm. The predictions it measures are fixed in advance, while the system's behavior in production depends on how people respond to what they are shown.

The reason this step matters is that changing the recommendations or search results a website shows can drastically change user behavior. A change that looks like a clear improvement in a test set can lead to unexpected consequences once people start reacting to it. Because of this, online testing is the usual next step after offline evaluation for systems that users see directly.

Key point

Offline evaluation measures predictions on data collected in advance. Online testing measures what happens when the algorithm is actually in front of users.

Splitting Users Into Two Groups

A/B testing is a common form of online testing. The procedure has three stages. First, users are divided into two groups and each group receives one algorithm. Second, relevant success metrics are recorded for both groups over a set period of time. Third, the metrics of algorithm A and algorithm B are compared, and a choice between the two approaches is made according to those metrics.

Follow one incoming user through this process. The user arrives, is placed into one of the two groups, and receives the algorithm assigned to that group. The diagram below shows the path every user takes. Notice that the two branches are the only place where the experience differs, and that both branches feed the same measurement and comparison steps.

Incoming userDivide into twogroupsGroup Areceives algorithm ARecord metricsover a set periodCompare metricsChoose approachGroup Breceives algorithm Barrivesgroup Agroup Bmetricsmetricsboth groupsaccording to metrics
Each incoming user is divided into group A or group B. Each group receives a different algorithm, and both groups' metrics are recorded and compared.

The users never need to know that a comparison is happening, which is why the study is described as blind. From the user's side, the experience looks normal. From the evaluator's side, the two groups are the controlled difference that the comparison depends on.

Which Algorithm Plays Which Role

A common arrangement is for algorithm A to be a new model and algorithm B to be the established system that is already running. The new model is tested against the current one on live traffic, so that the decision to adopt it rests on how users actually behave rather than on offline scores alone.

The main benefit of A/B testing is that it lets you evaluate algorithms in the wild. Because the users are interacting with the model in its real setting, the test can surface effects that no offline measurement would have predicted. This is the protection that most user-facing services rely on: a small portion of traffic absorbs the risk of a surprising change before it reaches everyone.

Measuring Consequences Inside the System

An algorithm is not evaluated in isolation. It is one stage in a path that runs from building a model, through offline checks, into live traffic, and finally into a decision. Online testing sits at the point where the algorithm meets real users, so the measurements it produces reflect the whole user-facing system rather than only the model's predictions.

Candidate modelOffline evaluationtest set collected inadvanceOnline testinglive user trafficRecorded metricsuser behaviorAdopt or rejectfirst checkencouraging resultconsequencescompare A and B
A model passes an offline check on a test set first, then moves to online testing on live traffic, where its metrics are compared before a decision is made.

The reason online testing is the usual next step is that the consequences of a change can travel through user behavior. A new ranking or recommendation changes what people click, and that change in behavior is exactly what the offline test set could not contain, because the test set was fixed before anyone reacted to the new output.

Comparing Click Rates Side by Side

Once the metrics have been recorded, the comparison can be as simple as computing a rate for each group. A common example metric is the fraction of visitors who clicked on a recommended item. Each group has its own count of visitors and clicks, and the click rate for each group is computed so the two can be placed side by side.

Rule

The script below uses illustrative counts (1000 visitors per group) chosen so that the resulting rates match the values in the source example. The counts are invented for teaching purposes and are not real experimental data.

python
Output (expected)
Group A click rate: 0.120
Group B click rate: 0.110
Difference (A minus B): 0.010
Notes on the code
  • Each group keeps its own visitor and click counts.
  • The same formula is applied to both groups so the rates are comparable.
  • The difference is only the starting point for interpretation.

Here group A shows a click rate of 0.120 and group B shows 0.110. Those two numbers are the raw material for the comparison step. Reading them correctly requires care: a difference in rates is only the starting point, and the test is designed around the metrics that were chosen in advance rather than whichever numbers happen to look best.

Visitors 1000Clicks 120Click rate 0.120Visitors 1000Clicks 110Click rate 0.110clicksdivideclicksdivide
Group A and group B are measured with the same metric. Their results sit in parallel columns so the two click rates can be compared directly.

Common Mistakes When Reading and Running A/B Tests

The procedure is simple to describe, but several errors come up repeatedly when people read or run these tests. The points below are drawn directly from how the test is meant to work.

  • Common mistake

    Treating any difference in rates as a decided winner

    What it looks like

    Group A shows 0.120 and group B shows 0.110, so A is declared the winner immediately.

    Why it fails

    A difference in rates is only the starting point for the comparison, not the full comparison.

    Do this instead

    Treat the difference as the input to a comparison that follows the planned design of the test.

  • Common mistake

    Choosing the success metric after seeing which numbers look best

    What it looks like

    After the results come in, the team picks whichever metric favors the new model.

    Why it fails

    The test is designed around the metrics that were chosen in advance, so picking metrics afterward departs from that design.

    Do this instead

    Decide which success metrics matter before the test runs, and compare the groups on those metrics.

  • Common mistake

    Assuming a strong offline score settles the question

    What it looks like

    A model scores well on the pre-deployment test set, so it is released to all users without a live comparison.

    Why it fails

    Offline predictions are fixed in advance, while user behavior in production depends on how people respond to what they see.

    Do this instead

    Use online testing on live traffic to measure the consequences before adopting the change widely.

  • Common mistake

    Forgetting that the two groups must receive different algorithms

    Why it fails

    If both groups receive the same experience, the comparison cannot reveal the effect of the algorithm change.

    Do this instead

    Confirm that group A and group B each receive their assigned algorithm throughout the recording period.

Beyond Two Fixed Groups

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 example. A/B testing is a well-established starting approach within a larger set of options.

You do not need to master bandit algorithms to understand the core idea of live evaluation, but it is useful to know they exist when a simple two-group comparison is not the right fit.

Checking Your Reading of a Test Result

What do you think happens?

If the team picks the success metric after seeing which one favors the new model, does the comparison still follow the test's design?

  • Yes, because any metric that shows a gain is valid

  • No, because the test is designed around metrics chosen in advance

Reveal answer
Answer:

No, because the test is designed around metrics chosen in advance

The source states that the test is designed around the metrics chosen in advance rather than whichever numbers happen to look best. Choosing the metric after seeing results departs from that design.

MEDIUM

A test records 0.120 for group A and 0.110 for group B on the click-rate metric. Explain what this difference tells you immediately, and what else you would need to know before deciding which algorithm to adopt.

Hints
  • Look at what the source says the difference represents.
  • Think about the metrics that were chosen in advance and the period over which they were recorded.
  • Consider whether a live comparison was needed in the first place.
EASY

Describe, in order, what happens to one incoming user in an A/B test, from arrival to the algorithm they receive, and name the step where the two groups are compared.

Hints
  • Start with the division of users into two groups.
  • Remember that metrics are recorded over a set period before the comparison.

Key Takeaways

  • Offline evaluation on a test set is a necessary first step, but it cannot show how real users respond to a changed system.
  • A/B testing splits users into two groups, gives each group a different algorithm, records metrics for both, and compares them.
  • A common arrangement tests a new model (A) against the established system (B) on live traffic, with the success metrics chosen in advance.
  • A difference in click rates such as 0.120 versus 0.110 is only the starting point for a comparison that follows the planned test design.
  • Bandit algorithms are a more elaborate form of online testing that goes beyond the basic two-group A/B split.

More concepts starting with U