Concepts / Evaluating Machine Learning Systems in Production

Evaluating Machine Learning Systems in Production

Offline evaluation measures predictions that are fixed in advance.

  • Programming

A Model That Scores Well Before Launch

Imagine 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.

Follow one prediction from the moment the model makes it to the moment a real user responds. The path it takes is what separates offline evaluation from online testing, and it is the thread that runs through the rest of this article.

Where a Prediction Goes After It Is Made

Offline evaluation measures predictions that are fixed in advance. The model is run on a previously collected test set, its outputs are scored, and the scores are the result. Nothing the model shows is seen by a person, so nothing a person does can feed back into the measurement.

In production, the same prediction does not stop at the score. It is shown to a user, the user responds, and that response is recorded as a metric. The diagram below traces this path. The offline branch ends at a fixed score, while the online branch loops through a person and returns real behavior to the team.

Model predictionFixed test setOffline scoreShown to userUser responseRecorded metricscored on past datafixed resultplaced in front of userspeople reactbehavior recorded
Where does the model's prediction travel after it is made, and how do real user responses flow back to produce metrics that offline evaluation cannot see?

Why Offline Scores Are Not Enough

Definition

Online testing is the measurement of real consequences of an algorithm once it is part of the live system and real users are interacting with it. Offline evaluation is the first step, but user-facing systems also need online testing to see what actually happens.

Offline evaluation has real advantages. 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. Those advantages are why it is the necessary starting point. The limitation is that the predictions it measures are fixed in advance, while the behavior of the system in production depends on how people respond to what they are shown.

This matters because changing the recommendations or search results a website shows can drastically change user behavior. A change that looks like a clear improvement on a test set can lead to unexpected consequences once people start reacting to it. For systems that users see directly, online testing is therefore the usual next step after offline evaluation.

How an A/B Test Splits Users

A/B testing is the most widely used form of online testing described in this material. Its 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.

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 the decision to adopt it rests on how users actually behave rather than on offline scores alone. Follow a single user through the flow below: they enter the system, get assigned to one group, and their data is recorded under that group.

User enters systemAssign to a groupGroup A: algorithm ARecord metrics for ACompare the twogroupsGroup B: algorithm BRecord metrics for Bgroup Agroup Bover a set periodover a set period
What path does a single user take from entering the system to being assigned to group A or group B, and where does each group's data get recorded?

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

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. The example below is a hypothetical one with invented counts, using a metric that 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 the number of clicks divided by the number of visitors.

Worked example

Click rate for group A and group B

Group A had 1200 visitors and 144 of them clicked a recommended item. Group B had 1000 visitors and 110 of them clicked. Compute the click rate for each group and compare them. The counts are invented for illustration.

  1. 1
    Group A rate

    Divide clicks by visitors: 144 divided by 1200 gives 0.120.

  2. 2
    Group B rate

    Divide clicks by visitors: 110 divided by 1000 gives 0.110.

  3. 3
    Place side by side

    Group A shows 0.120 and group B shows 0.110, so the raw difference is 0.010 in favor of group A.

  4. 4
    Read with care

    The difference is only the starting point. The comparison should rest on the metric chosen in advance, and the question of whether a gap this size is larger than random variation still needs to be answered before a decision is made.

Result

Group A has a click rate of 0.120 and group B has 0.110. The raw difference is a starting point for the comparison, not a conclusion on its own.

FeatureOffline evaluationOnline testing
Data usedTest set collected before deploymentLive traffic from real users
PredictionsFixed in advanceShown to people who respond
Cost of repeatingCheap to repeatRequires live traffic over a set period
Exposure of real usersNoneA portion of traffic sees the change
Can reveal unexpected effectsLimited to what the test set capturesYes, because behavior is measured in the wild

Offline evaluation and online testing answer different parts of the same question.

Mistakes When Reading and Running A/B Tests

The comparison step is where most errors happen. The mistakes below all come from treating a number as more settled than the test allows.

  • Common mistake

    Treating a raw difference in rates as a conclusion

    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 of the comparison. It has not yet been checked against random variation.

    Do this instead

    Treat the gap as a candidate result and check whether it is large enough to distinguish from chance before choosing an approach.

  • Common mistake

    Choosing the metric after seeing which numbers look best

    What it looks like

    After the results come in, the team picks whichever metric happens to favor the new model.

    Why it fails

    The test is designed around the metrics chosen in advance. Picking a metric afterward makes the comparison meaningless.

    Do this instead

    Fix the success metrics before the test starts and compare the groups on those metrics.

  • Common mistake

    Judging the new model only by its offline score

    What it looks like

    A model scores well on the test set collected before deployment, so it is adopted without live testing.

    Why it fails

    Predictions measured offline are fixed in advance, and they may not reflect how people change their behavior once the model is shown to them.

    Do this instead

    Run an online test on live traffic before deciding, so that the adoption decision reflects actual user behavior.

  • Common mistake

    Checking results repeatedly during the test and acting on the first apparent gap, which can make an early and unreliable difference look like a finding

Bandit Algorithms as Elaborate Online Tests

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.

The loop below shows what distinguishes the bandit approach. Each user's response feeds back into the algorithm's next decision, so the traffic it sends to each option can change over successive rounds. In a fixed two-group split, the groups stay the same for the duration of the comparison. In the bandit loop, the allocation of traffic is revised as responses arrive.

Show an optionUser respondsRecord the responseChoose next optionnext round
How does each user's response feed back into the algorithm's next decision, so that traffic shifts toward better-performing options over successive rounds?

Predicting Which Group Performs Better

What do you think happens?

Using the hypothetical click rates from the worked example, which group had the higher click rate: group A or group B?

  • Group A

  • Group B

  • They are equal

Reveal answer
Answer:

Group A, with a click rate of 0.120 compared with 0.110 for group B.

Click rate is clicks divided by visitors. Group A's 144 clicks out of 1200 visitors gives 0.120, and group B's 110 clicks out of 1000 visitors gives 0.110. The raw difference does not by itself establish that the gap is real, which is why the comparison still has to be checked.

MEDIUM

A team has an offline score showing that a new recommendation model beats the current one on a pre-collected test set. Explain in two or three sentences why the team should still run an online test before replacing the current model, and name one thing they should decide before the test starts.

Hints
  • Think about what the offline predictions are fixed in advance and what the system does once people see them.
  • The source stresses that the test is designed around metrics chosen in advance.

Key Takeaways

  • Offline evaluation is a necessary starting point because it is cheap, safe, and allows identical-input comparisons, but for user-facing systems it cannot show how people will respond to what they are shown.
  • A/B testing splits users into two groups, each receiving one algorithm, records success metrics for both over a set period, and compares the results to choose between the approaches.
  • The comparison should rest on metrics chosen in advance, and a raw difference in rates must be checked before it is treated as a conclusion.
  • Bandit algorithms are more elaborate online testing mechanisms in which each user's response feeds back into later decisions, shifting traffic over time.

Related concepts

More concepts starting with E