Back to Course
Experimentation

A/B Testing for Machine Learning

While A/B testing is a general experimentation technique, it plays a specific and critical role in machine learning: validating that a new model actually performs better than the current one in the real world, not just on a static test set.

Why Offline Metrics Aren't Enough

A model can score well on offline metrics like accuracy or RMSE but still fail to improve real business outcomes once deployed, due to shifts in live data or downstream effects not captured in historical data. A/B testing closes that gap.

Typical ML A/B Test Setup

GroupWhat They See
ControlPredictions from the current production model
TreatmentPredictions from the new candidate model

Traffic is randomly split between the two, and a business metric (click-through rate, conversion, revenue) is compared between groups using a statistical significance test.

Best Practices for ML A/B Testing

  • Pick One Primary Metric: Avoid overloading the test with too many success criteria.
  • Run Long Enough: Capture enough traffic and time to reach statistical power.
  • Monitor Guardrail Metrics: Ensure the new model doesn't hurt other important metrics.
  • Shadow Testing First: Run the new model silently alongside production before a live A/B test.

Common Pitfalls

  • Comparing models trained on different time windows, introducing bias.
  • Stopping the test too early once results look favorable.
  • Ignoring interaction effects between the new model and other running experiments.
Key Takeaway: A model isn't proven better until it wins a live A/B test — offline metrics are a filter, not a final verdict.

Ready to master Machine Learning?

Build real-world machine learning skills with hands-on projects, mentor-led sessions, and industry-relevant tools.

Explore Course