Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧪 A/B Test Decision Framework

Upload your experiment results, get a defensible ship / no-ship decision. A web app that turns a raw CSV of A/B test data into a recommendation backed by a fixed-horizon test, an always-valid sequential test (mSPRT), and a power analysis — plus a pre-experiment sample-size planner.

🔗 Live demo: https://ab-framework.streamlit.app — opens on a populated decision dashboard (no upload needed); switch between a clear winner, a null, and a borderline result, or drop in your own CSV.

App screenshot

Who this is for

Product managers, growth analysts, and data scientists who run experiments and need to answer three questions without re-deriving the statistics each time:

  1. Did it work? — lift, significance, and a confidence interval you can quote.
  2. Can I stop early? — an always-valid test that makes peeking safe.
  3. Should I ship it? — a transparent verdict tied to your effect-size bar.

What it does

  • Upload a CSV with columns variant (control/treatment), user_id, conversion (0/1), and optional revenue.
  • Headline stats — sample size and conversion rate per variant, absolute and relative lift, two-proportion z-test p-value, and 95% CIs on both lifts.
  • Power — achieved power at the observed effect, and (more usefully) power to detect your minimum detectable effect at the sample size you reached.
  • Always-valid sequential panel — an mSPRT confidence sequence plotted over the life of the experiment, telling you whether and when you crossed a valid stopping boundary.
  • Decision — a Ship / Do Not Ship / Keep Running verdict with a full audit trail of every criterion.
  • Planner tab — enter baseline rate, MDE, alpha, and power; get the required sample size per variant before you launch.

Three example datasets in examples/ land instantly on a clear winner, a (well-powered) null, and a borderline result.

Statistical methodology

Fixed-horizon test. Conversion rates are means of Bernoulli outcomes, so a two-proportion z-test applies. The hypothesis test uses the pooled-variance statistic (correct under H0: p_t = p_c); the confidence interval on the difference uses the unpooled variance. Cross-checked against statsmodels in the test suite.

Always-valid inference (the part most A/B tools get wrong). Classical p-values are only valid if you fix the sample size in advance — "peeking" and stopping when you see significance inflates the false-positive rate badly. This app implements the mixture Sequential Probability Ratio Test (mSPRT) with a zero-mean normal mixing distribution over the effect (Johari et al. 2017/2022; Lindon & Malek 2022). The mixture likelihood ratio Λₙ is a test martingale, so by Ville's inequality the anytime-valid p-value min(1, 1/Λₙ) can be monitored continuously with type-I error controlled at any stopping time. Inverting the test yields a confidence sequence — an interval that covers the true lift at all sample sizes simultaneously. The test suite verifies the type-I guarantee by simulation.

Decision logic. Ship requires a positive effect that is both statistically resolved (fixed-horizon significance or a crossed always-valid boundary) and practically meaningful (observed lift ≥ your MDE). A significant-but-tiny effect, or a well-powered null, returns Do Not Ship. Everything else is Keep Running.

Run locally

pip install -r requirements.txt
streamlit run streamlit_app.py
# regenerate the example datasets (optional):
python examples/generate_examples.py
# run the test suite:
pytest -q

Deploy (Streamlit Community Cloud, free)

The repo is deploy-ready: streamlit_app.py and requirements.txt live at the root. Go to https://share.streamlit.io, connect this repository, pick the main branch and streamlit_app.py, and claim the subdomain ab-framework. Every push to main auto-redeploys.

Project layout

streamlit_app.py        # the app (UI only; stats live in src/)
src/
  ab_stats.py           # two-proportion test, CIs, power, sample size
  sequential.py         # mSPRT: anytime-valid p-value + confidence sequence
  decision.py           # ship / no-ship / keep-running logic
examples/               # winner / null / borderline CSVs + generator
tests/                  # pytest: stats vs statsmodels, mSPRT type-I control
.github/workflows/ci.yml

Tech

Python · Streamlit · scipy.stats · statsmodels · pandas · plotly · pytest

About

Streamlit web app that turns raw A/B test CSVs into a ship/no-ship decision: two-proportion test, always-valid mSPRT sequential inference, power analysis, and a sample-size planner.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages