CLOUD CONCEPT

Hypothesis Testing

Hypothesis testing uses sample data to evaluate whether evidence supports rejecting a defined claim about a population or system.

Cloud Concepts Hub →

What is Hypothesis Testing

In production machine learning, hypothesis testing helps determine whether an observed difference between models reflects a real effect rather than sampling variation. Combined with randomized A/B testing, it supports evidence-based deployment decisions while accounting for uncertainty, business impact, and operational risk.

Hypothesis testing starts with a precise question, a measurable outcome, and competing statistical claims. For example, an engineering team might ask whether a new recommendation model increases purchase conversion compared with the production model. For a prespecified one-sided superiority test, the null hypothesis states that the new model provides no improvement, while the alternative states that it improves conversion. Choose the direction of the test before examining results; a two-sided test instead evaluates differences in either direction.

In a production A/B test, the existing model serves a control group and the candidate model serves a treatment group. Random assignment helps make the groups comparable so that differences in outcomes can be attributed to the model change. Choose the assignment unit carefully: when users make repeated requests, stable user-level assignment usually prevents them from switching treatments. Statistical analysis must also account for dependence among observations from the same user rather than treating every request as independent.

Cloud inference platforms can host multiple model variants and distribute requests using traffic weights. However, weighted routing alone does not guarantee stable user cohorts. Applications may need deterministic assignment and explicit variant targeting. Record the experiment identifier, assigned variant, model version, prediction timestamp, and outcome identifiers so that predictions can be joined with delayed labels or business events. Latency and error rates are immediately observable, but accuracy, fraud losses, and conversion often require later ground truth.

Before launching, define the primary metric, significance level, minimum detectable effect, target statistical power, and analysis plan. Sample-size requirements depend on baseline performance, outcome variability, allocation, and the effect size worth detecting. A small treatment allocation limits exposure to a harmful model but typically increases the time needed to establish an improvement. The experiment should also cover relevant business cycles and allow enough time for outcomes to mature.

A p-value measures how incompatible the observed result is with the null hypothesis under the test's assumptions: it is the probability, assuming the null, of a result at least as extreme as the one observed. It is not the probability that the null hypothesis is true. Compare the p-value with the prespecified significance level, but also examine the estimated effect and its confidence interval. An improvement from 10.0% to 10.1% conversion may be statistically significant with sufficient traffic yet still fail to justify additional inference cost.

Select a statistical method appropriate to the metric and experimental design. A two-proportion test can suit independent binary conversion outcomes, while continuous or heavily skewed metrics may require other methods. Repeatedly checking ordinary fixed-horizon p-values and stopping when significance appears inflates false-positive risk. Use a predefined analysis point or a valid sequential method, and address multiple comparisons when testing many variants or outcomes.

Monitor guardrails such as tail latency, request failures, cost, and harmful predictions throughout the experiment. Operational safety thresholds can justify stopping exposure before the statistical analysis is complete. Conversely, a nonsignificant result does not establish equivalence; it may indicate insufficient evidence or inadequate power. Shadow testing cannot directly measure user responses to candidate predictions because those predictions are not served to users, and drift monitoring alone does not establish which model performs better. Promote a candidate only when the evidence, practical benefit, and guardrails support the decision, then continue monitoring after rollout.

Key aspects of Hypothesis Testing

Reliable hypothesis testing combines predefined questions, valid experimental assignment, adequate data, appropriate statistical analysis, and operational safeguards.

Explicit hypotheses and decision criteria

Define the null and alternative hypotheses, primary outcome, test direction, and significance level before collecting experimental results. This prevents choosing a favorable interpretation after observing the data.

Randomization and stable assignment

Randomly assign comparable experimental units to control and treatment. Keep users in consistent variants when repeated exposure could affect behavior, and analyze results at an appropriate unit of independence.

Power and sample-size planning

Plan the experiment around a minimum meaningful effect and a target probability of detecting it. Lower traffic allocations, noisier metrics, and smaller effects generally require longer experiments.

Effect size and uncertainty

Evaluate the estimated improvement and its confidence interval alongside statistical significance. A detectable change may be too small to justify higher cost, latency, or operational complexity.

Reliable outcome attribution

Join model assignments and predictions with ground truth or business outcomes using durable identifiers. Account for delayed labels, missing outcomes, and differing observation windows before comparing variants.

Controlled repeated analysis

Use a planned analysis schedule or a statistically valid sequential approach instead of repeatedly checking ordinary p-values. Adjust the analysis when multiple comparisons could increase false-positive risk.

Operational guardrails

Monitor reliability, latency, cost, and safety independently of the primary experimental metric. Stop unsafe exposure when necessary, and distinguish emergency rollback decisions from conclusions about statistical superiority.

Cloud services for Hypothesis Testing

Amazon SageMaker AI serves control and candidate models through production variants, while application logic maintains stable assignments when the experiment requires them. Amazon CloudWatch tracks operational guardrails so engineers can respond to latency or reliability regressions during exposure. Amazon S3 stores captured inference records, assignment data, and delayed outcomes, and Amazon Athena joins and summarizes those records into analysis-ready datasets. Statistical code then evaluates the predefined hypotheses using an appropriate test, effect estimates, and confidence intervals. Together, these services provide deployment, observation, and data preparation; experiment design and statistically valid promotion criteria remain engineering responsibilities.

Amazon SageMaker image Amazon SageMaker

Real-time endpoints support production variants with configurable traffic weights, enabling control and treatment model deployments. Applications can explicitly target variants for stable cohort assignment; traffic routing does not itself perform hypothesis tests or establish statistical significance.

Open Amazon SageMaker →
Amazon CloudWatch image Amazon CloudWatch

Monitor endpoint and variant metrics such as invocation errors and latency, and publish custom experiment metrics where needed. Alarms can signal guardrail violations, but ordinary metric alarms do not establish that one model is statistically superior.

Open Amazon CloudWatch →
Amazon Simple Storage Service image Amazon S3

Store captured inference data, experiment assignments, and delayed outcomes for reproducible analysis. SageMaker AI data capture can write inference inputs and outputs to S3, while applications must supply the identifiers and outcome records needed for attribution.

Open Amazon S3 →
Amazon Athena image Amazon Athena

Query experiment records in S3 to join predictions with outcomes and aggregate metrics by variant and assignment unit. Use these prepared datasets in statistical analysis code; SQL summaries alone do not validate experimental assumptions.

Open Amazon Athena →