Sub topic 2
What Offline Evaluation Tells You and What It Cannot
The working model
Assume you can serve a model behind an HTTP or RPC endpoint, understand common metrics such as accuracy and latency, and know basic probability. Offline evaluation means testing a model on data collected before deployment. The data includes inputs and, ideally, the correct outcomes called labels.
A typical evaluation splits data into:
- A training set used to fit model parameters.
- A validation set used to choose features, hyperparameters, or a decision threshold.
- A test set used once for a final, less-biased estimate.
For production models, use a split that resembles how predictions will arrive. A random split may be reasonable for independent events. A time-based split is safer when user behavior, inventory, fraud patterns, or policies change over time.
records = [
{"time": 1, "score": 0.2, "label": 0},
{"time": 2, "score": 0.8, "label": 1},
{"time": 3, "score": 0.7, "label": 0},
{"time": 4, "score": 0.9, "label": 1},
{"time": 5, "score": 0.4, "label": 0},
{"time": 6, "score": 0.6, "label": 1},
]
records.sort(key=lambda row: row["time"])
cut = int(len(records) * 0.67)
test = records[cut:]
threshold = 0.5
correct = sum(
(row["score"] >= threshold) == bool(row["label"])
for row in test
)
accuracy = correct / len(test)
print(f"test examples: {len(test)}")
print(f"accuracy: {accuracy:.2f}")Offline metrics answer a narrow question: how well did this model predict known labels for this sample under this evaluation procedure? They do not prove that users will receive better results after release.
What offline evaluation can reveal
Compare the candidate with the current production model on the same examples. Use metrics that match the error cost:
| Model problem | Useful offline measures |
|---|---|
| Unequal classification errors | Precision, recall, F1, and a confusion matrix |
| Ranking or recommendation | Precision@k, recall@k, NDCG, or hit rate |
| Numeric prediction | Mean absolute error or root mean squared error |
| Probability quality | Log loss, calibration, and reliability by score range |
Inspect results by important slices, such as country, device type, customer group, or data freshness. A higher overall score can hide a severe regression for a small but important group.
What offline evaluation cannot prove
Offline data may not represent future traffic. This is called distribution shift: the relationship between inputs and outcomes changes after deployment. New products, attacks, policies, or seasonal behavior can invalidate yesterday's measurement.
Labels can also be delayed or selective. For example, a fraud label may arrive weeks later, and only investigated transactions receive a label. An offline score calculated from early labels may favor the wrong model.
A model can predict well without improving the business outcome. Recommendations can increase clicks but reduce purchases. A classifier can improve recall while adding too many costly reviews. Offline evaluation also cannot show production latency, capacity failures, downstream errors, or how users react to changed predictions.
The practical conclusion is to treat offline evaluation as a filter, not a release decision. Reject candidates with poor quality or serious slice regressions offline. Then use a controlled production rollout to measure live behavior and operational risk.
Exercise
A candidate model has better test accuracy but much worse recall for a small high-risk customer group. Should it be released based on the offline score alone?
Show answer
No. Investigate the slice regression and its cost, then validate the candidate through a controlled production rollout only if the risk is acceptable.