Bayesian Decision Analysis: A Tutorial in Python#
This is self-study material: the workshop is not offered live now, but the notebooks are maintained and run on Colab. For a newer version that uses PyMC, see Bayesian Decision Analysis with PyMC.
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. In addition to the bandit strategy, the slides summarize two other applications of BDA, optimal bidding and deriving a decision rule.
The examples in this tutorial are from my book, Think Bayes.
Level: introductory. You should be familiar with Python at an intermediate level, and with Jupyter notebooks. 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.
Length: about 90 minutes.
The notebook#
The page on this site shows the notebook with solutions. To do the exercises, run the version with blanks on Colab:
From Bayes’s Theorem to Bayesian Bandits: the five urn problem, Bayesian updates with a pandas
Series, and the Bayesian bandit with Thompson sampling. Exercises on Colab
Extended version#
An earlier, longer version of the workshop covers the same material in four notebooks. They run on Colab; each link opens the version with blanks, which links to the solutions.
Bayes’s Theorem: the cookie problem and Bayes tables.
Distributions: the 101 Bowls problem and probability mass functions.
Bayesian Statistics: the Euro problem, priors, and credible intervals.
Bayesian Bandits: Thompson sampling.
Recordings#
I presented this tutorial at ODSC East 2022 and PyData Global 2022. The recording is from PyData Global 2022. The code in the video is an earlier version; the repository README lists the version that goes with it.
Next steps#
For a newer version of this workshop that uses PyMC, see Bayesian Decision Analysis with PyMC. To go further, read Think Bayes, which is free online, or see my other workshops.
The code is on GitHub, under the MIT License; the text is under CC BY-NC-SA 4.0.