Measuring Impact of a Spam Filter on Friend Request Acceptance
Statistics & ExperimentsModel answerLast updated
Design an A/B test to measure how a tighter spam filter affects 24-hour friend-request acceptance, including randomization, metrics, power, and missing labels.
You're rolling out a tighter spam filter for friend requests and need to measure its effect on user engagement, specifically whether it improves legitimate acceptance rates within the first 24 hours.
Design a complete experiment to answer this question. Your design should address:
a) Hypothesis formulation
Define your primary hypothesis clearly (focus on 24-hour acceptance). Propose at least two guardrail metrics to ensure you're not degrading the product. State null and alternative hypotheses with precision.
b) Randomization strategy
Choose an experimental unit and assignment scheme. Friend requests involve two users—sender and receiver—so network interference is a real concern. Explain your randomization approach, justify it, and discuss residual spillover risks.
c) Metric definitions
Specify how you'll measure 24-hour acceptance. Be precise: define time windows, timestamp boundaries, and how you'll handle requests accepted after midnight or several days later.
d) Sample size and testing plan
Estimate required sample size. State your baseline assumption, minimum detectable effect, and how you'll account for clustering or correlation. Outline test duration and any plan for interim analysis with proper error control.
e) Incomplete spam labels
Not all requests have ground-truth spam labels—some are unclassified. Explain how missing labels could bias your metrics and propose two concrete strategies to address this bias. Describe how you'd present results given these adjustments.
Hints
Hint 1
A stricter filter changes who sends requests, not just who receives them—think about denominator effects on acceptance rates.
Hint 2
Randomizing by sender or receiver alone creates interference; consider clustering the social graph to contain spillover.
Hint 3
Define 'same-day' carefully: calendar day depends on time zone, but a rolling 24-hour window from send time is universal and fair.
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
Model Answer: Spam Filter Experiment Design
This question tests whether you can design a causally valid experiment in a networked setting with practical complications: two-sided interference, composition effects, incomplete observability, and the need for guardrails.
(a) Hypotheses
The composition problem
A stricter filter blocks more spam. If spam requests are rarely accepted, removing them mechanically raises the acceptance rate—even if no legitimate user changes behavior. To measure a causal effect, define the primary metric over a fixed population of senders present in both arms.
Primary metric: 24-hour acceptance rate among requests from pre-experiment eligible senders—accounts that existed before launch and were not flagged as spam in the week prior.
Primary hypothesis:
- H₀: μ_treatment − μ_control = 0
- H₁: μ_treatment − μ_control ≠ 0 (two-sided, α = 0.05)
where μ is the mean per-recipient 24-hour acceptance rate.
Guardrail metrics (one-sided tests, each with a pre-set harm threshold):
-
Legitimate requests sent per active sender per day
H₀: Δ ≤ −1% relative | H₁: Δ > −1%
(Ensure the filter doesn't discourage legitimate sending.) -
Time to acceptance (median and 90th percentile)
H₀: Δ ≥ +5% | H₁: Δ < +5%
(Check that stricter filtering doesn't slow down acceptance for legitimate requests.) -
False-positive rate (audit sample)
H₀: FP_treatment − FP_control ≥ 0.2pp | H₁: FP_treatment − FP_control < 0.2pp
(Manual review of a sample to estimate how many legitimate requests were wrongly blocked.)
(b) Randomization and network interference
The interference problem
- Randomizing by recipient is clean for measuring inbox quality, but senders whose requests get blocked in treatment may reduce sending globally—biasing control results.
- Randomizing by sender lets you measure sender behavior, but every recipient sees a mix of treated and untreated requests, diluting the effect.
Recommendation: graph-cluster randomization
- Partition the social graph into clusters using community detection (Louvain, label propagation, or geographic/school clusters as a proxy). Target 5,000–10,000 clusters.
- Randomize at the cluster level (50/50 split).
- Apply the filter based on the recipient's cluster assignment.
Most legitimate requests stay within clusters, so most sender–receiver pairs share the same treatment arm. This limits cross-arm interference.
Residual spillover and mitigation
- Cross-cluster requests: Measure what fraction of requests cross treatment boundaries. Report a sensitivity analysis restricted to within-cluster requests.
- Spammer volume shifting: Spammers operate globally and may shift effort toward the control arm if treatment blocks them more. Compare control spam volume to its pre-period baseline; an increase signals displacement. Consider modeling this as a mediation effect if large.
- Direct measurement of interference: If feasible, run a small parallel arm with user-level randomization. The gap between user-level and cluster-level estimates quantifies interference magnitude.
Statistical inference: Use cluster-robust standard errors or a cluster-level analysis (sum accepts and sends per cluster, compute the ratio, then difference across arms with a t-test).
(c) Metric definitions
Timestamp conventions
- All timestamps are UTC.
- Each request is tagged with its send timestamp.
Primary: 24-hour acceptance
Define acceptance as occurring within a rolling 24-hour window from send time:
accepted_at − sent_at ≤ 24 hours
This avoids time-zone bias and gives every request the same opportunity window. A request sent at 11:50 PM still has 24 hours to be accepted.
Maturity rule: Only include requests where sent_at ≤ data_cutoff − 24h. Requests still inside the window are excluded (not counted as rejections), ensuring unbiased estimation.
Calendar-day acceptance (accepted on the same UTC date as sent) can be reported as a secondary metric for consistency with existing dashboards, but it's noisier and time-zone dependent.
Secondary metrics
- 7-day acceptance rate (7-day maturity lag required)
- Requests received per recipient per day
- Spam reports per 1,000 delivered requests
- New friendships formed within 7 days
- Messages sent to new friends within 7 days (engagement quality check)
Handling delayed acceptances
Requests are grouped into daily cohorts by send date. A request sent Monday and accepted Tuesday (within 24 hours) counts toward Monday's cohort. Use cohort-level maturity windows to ensure fair comparison.
For acceptance latency, use survival analysis (Kaplan–Meier) since many requests remain pending. Compare median and 90th percentile time-to-acceptance across arms. Do not compute means over accepted-only requests—that introduces survivor bias.
(d) Sample size and power
Baseline assumptions
- Baseline 24-hour acceptance rate: p = 0.40
- Minimum detectable effect: δ = 0.5pp (1.25% relative lift)
- α = 0.05 (two-sided), power = 80%
Naïve calculation (independent observations)
n = 2(z₀.₉₇₅ + z₀.₈)² · p(1−p) / δ²
n = 2 · (1.96 + 0.84)² · 0.24 / (0.005)²
n ≈ 150,000 requests per arm
Real-world adjustments
-
Clustering increases variance. The metric is a ratio (accepts / requests) clustered within recipients and graph clusters. The design effect is roughly 1 + (m − 1)·ICC, where m is average cluster size and ICC is the intra-cluster correlation. With ICC ≈ 0.01 and cluster sizes in the hundreds, the design effect can be 3–10×.
-
Calibrate variance from a pre-period A/A test using the same cluster assignments. Compute cluster-level acceptance rates and measure their variance directly.
-
Variance reduction with CUPED: Use each cluster's pre-period acceptance rate as a covariate. This typically reduces variance by 25–40%.
Practical target: Plan for 1–2 million eligible requests per arm and at least 3,000 clusters per arm.
Test duration
- Run for at least 14 full days to cover two weekly cycles and allow spammer adaptation.
- Add a 1-day maturity lag for the 24-hour metric and 7 days for secondary metrics.
- Extend if the A/A-calibrated variance requires more statistical power.
Sequential analysis
Pre-register interim looks at days 7, 10, and 14. Use group-sequential design with O'Brien–Fleming alpha spending to control Type I error:
- Day 7: p < 0.001
- Day 10: p < 0.01
- Day 14: p < 0.045
Alternatively, use an always-valid sequential test (mSPRT). Allow early stopping for harm on guardrails with a more lenient boundary, but never stop early on the primary metric before day 7 (to capture weekly patterns).
Apply Holm correction across the four guardrails to control family-wise error rate.
(e) Incomplete spam labels
The bias problem
Spam labels come from user reports, heuristics, and classifier confidence scores. Many requests have no label—especially newer spam that hasn't been reported yet. If you compute acceptance rates only over labeled requests, you'll miss:
- Spam that looks legitimate (high-quality spam, not yet reported)
- Legitimate requests misclassified as spam
This creates missing-not-at-random bias. Treatment may block more unlabeled spam, inflating the acceptance rate in ways you can't observe.
Mitigation strategy 1: Unknown bucket + sensitivity bounds
Partition requests into three groups: legit, spam, unknown.
Report metrics separately:
- Acceptance rate among known-legit requests (gold standard)
- Acceptance rate among all requests (includes unknowns)
- Acceptance rate among unknowns only
Sensitivity bounds: Assume unknowns are all spam (lower bound on treatment effect) or all legit (upper bound). If the confidence interval for the effect excludes zero under both extremes, the result is robust to label missingness.
Mitigation strategy 2: Inverse-probability weighting (IPW)
If labeling is missing at random (MAR) conditional on observables (e.g., sender age, request features, engagement history), estimate a propensity model for P(labeled | X) and reweight observations by the inverse of this probability.
Estimate the treatment effect as:
τ̂ = (1/n_T) Σ (Y_i · w_i | T_i=1) − (1/n_C) Σ (Y_i · w_i | T_i=0)
where w_i = 1 / P̂(labeled | X_i).
This reduces bias if the MAR assumption holds. Check balance: compare covariate distributions between labeled and unlabeled sets. Large imbalances suggest MAR is violated.
Reporting results
Present:
- Primary result on the known-legit subset (most interpretable).
- All-request result (operational metric, easier to compute at scale).
- Sensitivity analysis with bounds or IPW adjustment.
- Audit subsample: Manually label 500–1,000 requests per arm to estimate false-positive and false-negative rates and extrapolate.
State the assumptions clearly (MAR, audit sample representativeness) and flag remaining uncertainty. If bounds are wide or IPW reveals significant bias, recommend a follow-up experiment with richer labeling infrastructure before launch.
Common mistakes
- Ignoring composition bias: comparing raw acceptance rates across arms when treatment changes the sender mix.
- Using calendar days instead of rolling windows, biasing results by time zone.
- Ignoring network interference and randomizing at the user level without clustering.
- Assuming independent observations and vastly underestimating required sample size.
- Treating missing labels as missing completely at random and ignoring bias.
A strong answer demonstrates understanding of causal inference in networks, precise metric definition, realistic power calculations, and principled handling of incomplete data.