Skip to content

Commit aa1ee22

Browse files
author
Cuong Duong
authored
Bayesian A/B Testing Introduction - Apply best practices (#383)
* rename and use apply best practices * run pre-commit fixes * fixes * updates * rerun
1 parent 32e132e commit aa1ee22

File tree

4 files changed

+2278
-2204
lines changed

4 files changed

+2278
-2204
lines changed

examples/case_studies/bayesian_ab_testing.ipynb

Lines changed: 0 additions & 2196 deletions
This file was deleted.

examples/case_studies/bayesian_ab_testing_introduction.ipynb

Lines changed: 2241 additions & 0 deletions
Large diffs are not rendered by default.

examples/references.bib

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,12 @@ @article{spiller2013spotlights
432432
year = {2013},
433433
publisher = {SAGE Publications Sage CA: Los Angeles, CA}
434434
}
435+
@online{stucchio2015bayesian,
436+
title = {Bayesian A/B Testing at VWO},
437+
author = {Stucchio, Chris},
438+
year = {2015},
439+
url = {https://vwo.com/downloads/VWO\_SmartStats\_technical\_whitepaper.pdf}
440+
}
435441
@misc{szegedy2014going,
436442
title = {Going Deeper with Convolutions},
437443
author = {Christian Szegedy and Wei Liu and Yangqing Jia and Pierre Sermanet and Scott Reed and Dragomir Anguelov and Dumitru Erhan and Vincent Vanhoucke and Andrew Rabinovich},

myst_nbs/case_studies/bayesian_ab_testing.myst.md renamed to myst_nbs/case_studies/bayesian_ab_testing_introduction.myst.md

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,20 @@ jupytext:
66
format_version: 0.13
77
jupytext_version: 1.13.7
88
kernelspec:
9-
display_name: Python 3 (ipykernel)
9+
display_name: Python 3.8.10 ('pymc-examples-ipRlw-UN')
1010
language: python
1111
name: python3
1212
---
1313

14+
(bayesian_ab_testing_intro)=
15+
# Introduction to Bayesian A/B Testing
16+
17+
:::{post} May 23, 2021
18+
:tags: case study, ab test
19+
:category: beginner, tutorial
20+
:author: Cuong Duong
21+
:::
22+
1423
```{code-cell} ipython3
1524
from dataclasses import dataclass
1625
from typing import Dict, List, Union
@@ -38,7 +47,7 @@ plotting_defaults = dict(
3847
)
3948
```
4049

41-
This notebook demonstrates how to implement a Bayesian analysis of an A/B test. We implement the models discussed in VWO's [Bayesian A/B Testing Whitepaper](https://vwo.com/downloads/VWO_SmartStats_technical_whitepaper.pdf), and discuss the effect of different prior choices for these models. This notebook does _not_ discuss other related topics like how to choose a prior, early stopping, and power analysis.
50+
This notebook demonstrates how to implement a Bayesian analysis of an A/B test. We implement the models discussed in VWO's Bayesian A/B Testing Whitepaper {cite:p}`stucchio2015bayesian`, and discuss the effect of different prior choices for these models. This notebook does _not_ discuss other related topics like how to choose a prior, early stopping, and power analysis.
4251

4352
#### What is A/B testing?
4453

@@ -478,7 +487,7 @@ class RevenueModel:
478487

479488
For the Beta prior, we can set a similar prior to before - centered around 0.5, with the magnitude of `alpha` and `beta` determining how "thin" the distribution is.
480489

481-
We need to be a bit more careful about the Gamma prior. The mean of the Gamma prior is $\dfrac{\alpha_G}{\beta_G}$, and needs to be set to a reasonable value given existing mean purchase values. For example, if `alpha` and `beta` were set such that the mean was \\$1, but the average revenue per visitor for a website is much higher at \\$100, this could affect our inference.
490+
We need to be a bit more careful about the Gamma prior. The mean of the Gamma prior is $\dfrac{\alpha_G}{\beta_G}$, and needs to be set to a reasonable value given existing mean purchase values. For example, if `alpha` and `beta` were set such that the mean was 1 dollar, but the average revenue per visitor for a website is much higher at 100 dollars, his could affect our inference.
482491

483492
```{code-cell} ipython3
484493
c_prior = BetaPrior(alpha=5000, beta=5000)
@@ -654,19 +663,33 @@ There are many other considerations to implementing a Bayesian framework to anal
654663
* How do we plan the length and size of A/B tests using power analysis, if we're using Bayesian models to analyse the results?
655664
* Outside of the conversion rates (bernoulli random variables for each visitor), many value distributions in online software cannot be fit with nice densities like Normal, Gamma, etc. How do we model these?
656665

657-
Various textbooks and online resources dive into these areas in more detail. [Doing Bayesian Data Analysis](http://doingbayesiandataanalysis.blogspot.com/) by John Kruschke is a great resource, and has been translated to PyMC here: https://github.com/JWarmenhoven/DBDA-python.
666+
Various textbooks and online resources dive into these areas in more detail. Doing Bayesian Data Analysis {cite:p}`kruschke2014doing` by John Kruschke is a great resource, and has been translated to PyMC [here](https://github.com/JWarmenhoven/DBDA-python).
658667

659668
We also plan to create more PyMC tutorials on these topics, so stay tuned!
660669

661-
---
670+
+++
671+
672+
## Authors
662673

663-
Author: [Cuong Duong](https://github.com/tcuongd) (2021-05-23)
674+
* Authored by [Cuong Duong](https://github.com/tcuongd) in May, 2021 ([pymc-examples#164](https://github.com/pymc-devs/pymc-examples/pull/164))
675+
* Re-executed by [percevalve](https://github.com/percevalve) in May, 2022 ([pymc-examples#351](https://github.com/pymc-devs/pymc-examples/pull/351))
664676

665-
### References
677+
+++
666678

667-
* [Stucchio, C. (2015) _Bayesian A/B Testing at VWO_](https://vwo.com/downloads/VWO_SmartStats_technical_whitepaper.pdf)
679+
## References
680+
681+
:::{bibliography}
682+
:filter: docname in docnames
683+
:::
684+
685+
+++
686+
687+
## Watermark
668688

669689
```{code-cell} ipython3
670690
%load_ext watermark
671691
%watermark -n -u -v -iv -w -p aesara,xarray
672692
```
693+
694+
:::{include} ../page_footer.md
695+
:::

0 commit comments

Comments
 (0)