Holdout Test
How the holdout test measures the lift of the users served by the model against the holdout, and how to reproduce the numbers from the warehouse.
The holdout test is an A/B test of the optimization. It compares the users that the model served with the users in the holdout, a randomized control group that keeps the current experience. The result is the observed relative difference in the reward between the two groups.
The holdout test includes all users that the model served in the date range. This includes the traffic that the model used for exploration. See Lift for the difference between the holdout test and the current lift.
The result of the holdout test is shown in three places:
- The Holdout tab of the dashboard, which is shown when the optimization has a holdout.
- The "Measured" line of the
levered optimizations resultsCLI command. - The API.
All three use the same estimator and show the same number. The SQL and the formula on this page reproduce it from the warehouse.
The estimator
For a metric and a date range, Levered pools the users of each arm. It reports the relative lift with a delta-method confidence interval and a two-sided p-value.
The model arm (treatment) has rate p_model over n_model users. The holdout arm (control) has rate p_hold over n_hold users. For a boolean metric, the rate is conversions / users.
relative_lift = (p_model − p_hold) / p_hold (reported × 100 as a percent)The standard error of the relative lift is computed with the delta method:
var(p_model) = p_model · (1 − p_model) / n_model # boolean
var(p_hold) = p_hold · (1 − p_hold) / n_hold # boolean
se = 100 · sqrt( var(p_model) / p_hold² + p_model² · var(p_hold) / p_hold⁴ )
95% CI = relative_lift_percent ± 1.96 · se
p_value = 2 · (1 − Φ(|relative_lift_percent / se|))For a numeric metric, var per arm is stddev² / n instead of the binomial form. The other formulas are the same.
Levered reports a CI and a p-value only if each arm has at least 100 users. If the holdout rate is zero, the relative lift is undefined and is reported as blank.
The estimator pools the whole date range and does not stratify by day. The holdout percentage is fixed for the lifetime of an optimization, so the calendar day is not associated with the arm of a user, and pooling is unbiased. If an optimization ran under an older policy and its holdout percentage changed while it was live, do not pool across the change. Filter to a date range with a single holdout percentage before comparing.
Counts: the canonical definition
To reproduce the lift, count users in the same way as Levered. The counts per arm are at user level, with one row per user:
- One row per
anonymous_id. A user with multiple exposures counts once. The arm and the conversion window of the user are based on the first exposure of the user for the optimization. - Arm. Levered derives the arm from the holdout hash of the user id (see Holdout). It does not read the arm from a logged column. A logged
is_holdoutcolumn agrees with the hash if the id column contains the id that the SDK was called with. - Conversion. A user is converted if the user has at least one reward event with a timestamp within the conversion window of the optimization, measured from the first exposure (
exposure_ts ≤ reward_ts ≤ exposure_ts + window). Rewards are joined to exposures onanonymous_id. - Day boundaries. A date range filter uses UTC days.
- Open conversion windows. By default, the Holdout tab counts every user, including users whose conversion window has not ended yet. With Display options > Conversion window > Completed, it counts only the days on which the conversion window has ended for every user. The model counts users in the same way.
Reproduce it from your warehouse
The following Snowflake query reproduces the counts per arm for an optimization and a conversion window. Replace the exposure and reward tables, the optimization_id, the holdout percentage (10 in the query) and the window (24 hours in the query). Optionally add a date range on the day of the first exposure.
WITH first_exposure AS (
SELECT
anonymous_id,
MIN(timestamp) AS anchor_ts
FROM exposures
WHERE optimization_id = '<OPTIMIZATION_ID>'
GROUP BY anonymous_id
),
cohort AS (
SELECT
fe.anonymous_id,
-- arm = Levered's holdout hash of the id
MOD(TO_NUMBER(SUBSTR(SHA2(CONCAT('<OPTIMIZATION_ID>', ':', fe.anonymous_id), 256), 1, 8), 'XXXXXXXX'), 100) < 10
AS is_holdout,
fe.anchor_ts,
-- converted = a reward within the window of the first exposure
CASE WHEN EXISTS (
SELECT 1 FROM rewards r
WHERE r.anonymous_id = fe.anonymous_id
AND r.timestamp >= fe.anchor_ts
AND r.timestamp <= DATEADD(hour, 24, fe.anchor_ts)
) THEN 1 ELSE 0 END AS converted
FROM first_exposure fe
-- optional date range, on the first-exposure day, in UTC:
-- WHERE fe.anchor_ts >= '2026-05-31'
)
SELECT
CASE WHEN is_holdout THEN 'holdout' ELSE 'model' END AS arm,
COUNT(*) AS users,
SUM(converted) AS conversions,
AVG(converted) AS rate
FROM cohort
GROUP BY is_holdout;Enter the two (rate, users) pairs into the formulas in The estimator. The result is the same lift, CI and p-value as in the dashboard and the CLI.
Worked examples
The tests of Levered assert the following values (z = 1.96, minN = 100). Use them to check an implementation:
| p_model | n_model | p_hold | n_hold | Lift | 95% CI | p-value |
|---|---|---|---|---|---|---|
| 0.7239 | 50,689 | 0.7178 | 20,270 | +0.85% | [−0.18%, +1.88%] | 0.104 |
| 0.7265 | 33,672 | 0.7153 | 3,832 | +1.57% | [−0.57%, +3.70%] | 0.151 |
| 0.5000 | 1,000 | 0.5000 | 1,000 | 0.00% | [−8.77%, +8.77%] | 1.000 |