Interview concept

A/B Testing And Experiment Analysis For ML

Asked of: Machine Learning Engineer

Last updated

Editorial flowchart for validating an ML A/B test: define metrics, randomize users, verify exposure and parity, analyze uncertainty, check guardrails, then ship or investigate.

What's being tested

The interviewer is testing whether you can evaluate a machine-learning change as a production intervention rather than relying only on offline metrics such as AUC or NDCG. You should be able to design a valid randomized comparison, choose metrics tied to model behavior, detect instrumentation and rollout failures, and quantify uncertainty. General cares because an MLE owns the path from trained artifact to serving system, where leakage, feature skew, latency, and population drift can invalidate an apparently successful model.

Core knowledge

  • Randomization unit must match the independence assumption and treatment exposure: user-level assignment prevents cross-device contamination, while request-level assignment can be appropriate for stateless ranking but risks users seeing inconsistent experiences. Keep assignment sticky with a deterministic hash of user ID and experiment ID.

  • Define one primary metric before launch, such as conversion rate, qualified engagement, or revenue per eligible user. Add guardrail metrics for latency, error rate, complaint rate, and retention; a model should not win on clicks while materially degrading p99 latency or downstream quality.

  • For a binary outcome, estimate the treatment effect as Δ^=p^T−p^C\hat{\Delta}=\hat{p}_T-\hat{p}_C. For a ratio metric such as revenue per user, prefer user-level aggregation and the delta method or bootstrap confidence intervals rather than treating every event as independent.

  • Statistical power depends on baseline variance, minimum detectable effect, significance level, and sample size. For a rough two-arm proportion test, required sample size grows approximately as 1/MDE21/\mathrm{MDE}^2; halving the target effect requires about four times as many samples.

  • Use a predeclared confidence interval and decision rule, not merely “the treatment is positive.” A 95% interval crossing zero means the data do not establish improvement at that threshold; practical significance and operational cost still matter even when p<0.05p<0.05.

  • Check for sample-ratio mismatch (SRM): if a planned 50/50 split produces 53/47 exposure, investigate assignment, eligibility, logging, or delivery before interpreting outcomes. SRM is often a stronger signal of experiment invalidity than the model metric itself.

  • Preserve offline/online parity: compute features, labels, filtering, and candidate generation consistently between training and serving. Compare prediction distributions, feature missingness, score histograms, and slice-level outcomes; a successful offline replay cannot compensate for online feature skew.

  • ML experiments require both model metrics and system metrics. Track ranking metrics such as NDCG@k, recall, calibration, and coverage offline, then connect them to online outcomes while monitoring inference latency, timeout rate, memory, throughput, and fallback frequency.

  • Account for novelty effects, learning effects, and delayed labels. A recommendation model may initially benefit from fresh ranking or suffer from user adaptation, while fraud, retention, or subscription outcomes may mature over days or weeks; define the observation window before reading results.

  • Repeatedly checking results creates peeking bias and inflates false positives. Use a fixed analysis window, sequential-testing methods such as alpha spending, or an explicitly approved stopping rule; do not stop when a dashboard first turns green.

  • Segment analysis should be hypothesis-driven: inspect platform, geography, traffic source, new versus returning users, and model-confidence bands. Correct for multiple comparisons or label segments as exploratory; otherwise random subgroup noise will look like a real interaction.

  • Handle interference and exposure carefully. If users influence one another, or if treatment changes which items receive impressions, standard individual-level assumptions may fail; consider cluster randomization, switchback experiments, exposure-weighted metrics, or an intent-to-treat analysis.

Worked example

A/B Testing And Experiment Analysis For ML — Suppose the task is to evaluate a new ranking model in production. In the first 30 seconds, I would clarify the prediction surface, eligible population, randomization unit, primary business outcome, expected effect size, label delay, and whether treatment can alter inventory or exposure. I would organize the answer around four pillars: deterministic assignment and clean logging, offline parity checks, primary and guardrail metrics, and statistical analysis with launch criteria. I would first validate that both arms have comparable eligibility, traffic allocation, feature availability, score distributions, and serving latency before interpreting ranking quality. The primary analysis would be intent-to-treat at the user level, with confidence intervals and predeclared slices for important populations. I would explicitly flag the tradeoff between user-level randomization, which reduces contamination, and request-level randomization, which may provide more traffic but creates inconsistent user experiences. I would also account for delayed conversions and avoid declaring success from an early click-through lift alone. If I had more time, I would add a holdout for long-term retention, investigate treatment-control interference, and design a rollback threshold based on latency and reliability.

A second angle

For a model that predicts fraud rather than ranks content, the same framework shifts from engagement lift toward prevented loss, false-positive cost, review capacity, and customer friction. Randomization may need to occur at the account or merchant level because request-level assignment enables evasion and contamination. The primary metric should include eventual fraud loss, while early proxy metrics such as approval rate require calibration against delayed labels. I would also require strict safety guardrails because a statistically significant reduction in fraud is not acceptable if legitimate users are disproportionately blocked. The analysis would emphasize calibration, threshold policy, delayed outcomes, and slice-level fairness rather than only aggregate conversion.

Common pitfalls

Pitfall: Treating offline AUC or NDCG@k as proof of online value. These metrics measure predictive or ranking quality under a dataset distribution; a strong answer connects them to online outcomes and checks serving parity, latency, and exposure changes.

Pitfall: Saying “run a 50/50 A/B test and choose the higher mean” without defining the unit of randomization, primary metric, power, confidence interval, or stopping rule. State assumptions and explain how you would invalidate the experiment when SRM or logging problems appear.

Pitfall: Over-focusing on statistical significance while ignoring MLE failure modes. A candidate should discuss feature skew, model version mismatches, fallback behavior, timeout rates, delayed labels, and rollback criteria—not just calculate a pp-value.

Connections

The interviewer may pivot to model monitoring, data and concept drift, calibration and thresholding, counterfactual evaluation, or canary deployment. They may also ask how feature-store consistency, shadow traffic, and rollback design affect the validity of an online evaluation.

Further reading

  • Trustworthy Online Controlled Experiments: A Practical Guide to A/B Testing — rigorous treatment of experiment design, metric quality, SRM, and organizational experimentation practice.
  • Kohavi, Tang, and Xu, Trustworthy Online Controlled Experiments — especially useful for practical failure modes such as novelty effects, peeking, and violated randomization assumptions.
  • Microsoft Research, “Controlled Experiments on the Web: Survey and Practical Guide” — concise reference for power, guardrails, sequential analysis, and online experimentation pitfalls.

Related concepts