This repository contains slides and Jupyter notebooks for a tutorial on Bayesian Decision Analysis. Most recently I presented it at PyData Global 2022.
Abstract
This tutorial is a hands-on introduction to Bayesian Decision Analysis (BDA), which is a framework for using probability to guide decision-making under uncertainty. I start with Bayes's Theorem, which is the foundation of Bayesian statistics, and work toward the Bayesian bandit strategy, which is used for A/B testing, medical tests, and related applications. For each step, I provide a Jupyter notebook where you can run Python code and work on exercises. In addition to the bandit strategy, I summarize two other applications of BDA, optimal bidding and deriving a decision rule. Finally, I suggest resources you can use to learn more.
The examples in this tutorial are from Think Bayes.
Outline
- Problem statement: A/B testing, medical tests, and the Bayesian bandit problem
- Prerequisites and goals
- Bayes's theorem and the five urn problem
- Using Pandas to represent a PMF
- Estimating proportions
- From belief to strategy
- Implementing and testing Thompson sampling
- More generally: two other examples of BDA
- Resources and next steps
Prerequisites
For this tutorial, you should be familiar with Python at an intermediate level. We'll use NumPy, SciPy, and Pandas, but I'll explain what you need to know as we go. You should be familiar with basic probability, but you don't need to know anything about Bayesian statistics. I provide Jupyter notebooks that run on Colab, so you don't have to install anything or prepare ahead of time. But you should be familiar with Jupyter notebooks.
-
Here is the notebook with blank cells for you to fill in: Run it on Colab or Download it
-
Here is the notebook with solutions: Run it on Colab or Download it.
For the extended version of the workshop, here are the slides.
For each of the notebooks below, you have two options: if you view the notebook on NBViewer, you can read it, but you can't run the code. If you run the notebook on Colab, you'll be able to run the code, do the exercises, and save your modified version of the notebook in a Google Drive (if you have one).
Click here to run this notebook on Colab or click here to read it on NBViewer
Click here to run this notebook on Colab or click here to read it on NBViewer
Click here to run this notebook on Colab or click here to read it on NBViewer
Click here to run this notebook on Colab or click here to read it on NBViewer