TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Thoughts and Theory

How to Optimize your Switchback A/B Test Configuration

Michael Berk
TDS Archive
Published in
9 min readJun 8, 2021

--

Switchback Testing, Time Split Testing, A/B Testing, Data Science
Figure 1: switchback testing framework with 30 minute time splits — image by author.

0. Technical TLDR

Switchback Testing, Time Split Testing, A/B Testing, Data Science
Figure 2: expression that, when minimized, will produce the optimal randomization points with the smallest variance — source (Equation 8)

1. But, what’s actually going on?

1.1 When do we use switchback experiments?

1.2 Defintion of Switchback Experiments

Switchback Testing, Time Split Testing, A/B Testing, Data Science
Figure 3: illustration of the sequential randomization periods — image by author.

1.3 A Better Method

Switchback Testing, Time Split Testing, A/B Testing, Data Science
Figure 4: the expression we are looking to minimize to develop optimal randomization points. Duplicate of figure 2 — source (Equation 8)
Data Science, A/B testing, Switchback experiment
Figure 5: example from the paper of an optimal config (top row) and a randomly designed switchback (bottom row) — source (Table 1)

1.4 Intuition Behind the Method

Switchback Testing, Time Split Testing, A/B Testing, Data Science
Figure 6: leftmost summation of the minimization expression — source (Equation 8)
Switchback Testing, Time Split Testing, A/B Testing, Data Science
Figure 7: second lefmost summation of the minimization expression — source (Equation 8)
Switchback Testing, Time Split Testing, A/B Testing, Data Science
Figure 8: rightmost summation of the minimization expression — source (Equation 8)

2. Inference

2.1 Exact Method

sampled_lifts = []# 0. Calcualte lift using the Horvitz-Thompson esimtator for our full data
total_lift = hv_estimator(observed_assignment_path, observed_ys)
# 1. Iterate through a large number of samples
for i in range(num_samples):
# 2. Sample a new assignment path (w) according to the assignment mechanism
w = sampled_assigment_path(dist)

# 3. estimate our lift (lift) using the Horvitz-Thompson esimtator
lift = hv_estimator(w, observed_vals)
lifts.append(lift)
# 4. Calcualte p_value as the proprtion of samples that have higher lift than the total_lift
p_val = avg(abs(lifts) > abs(lift))
# 5. Examine values of interest
print(total_lift, p_val)

2.2 Asymptotic Method

Implementation Notes

--

--

TDS Archive
TDS Archive

Published in TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Michael Berk
Michael Berk

Responses (6)