Bayesian Beasts: Iterative modelling with PyMC

Teemu Sailynoja

2025-08-26

Agenda

  • Me: Hi!
  • Bayes
    • What & Why
  • Korkeasaari
    • Data Peek
    • Questions Asked
    • Baseline Model
    • Model Iterations
    • Questions Answered

Me: Teemu Säilynoja

🎓 Doctor of Science Candidate

Wrapping up my DSc at Aalto University.

  • Workflow of Bayesian model building

💼 Consultant for PyMC Labs

Applying Bayesian methods to real-world problems.

  • Marketing analytics (Media Mixed Models)

🛠️ Open Source

Contributing to Bayesian modelling ecosystem in Python and R.

Bayes: What

“Bayesian inference is a method of statistical reasoning that updates our beliefs about unknown quantities using observed data.”

Bayes: What

\[ \color{orange}{P( \theta \mid y)} = \frac{\color{blue}{P(y \mid \theta)}\color{red}{P(\theta)}}{P(y)} \]

  • Posterior: Belief of parameters after seeing the data
  • Likelihood: How likely the observed data is, given the parameters
  • Prior: What we think before seeing the data
  • “Normalizing constant”

Bayes: What

\[ {P( \theta \mid y)} = \frac{{P(y \mid \theta)}{P(\theta)}}{\color{red}{\displaystyle \int P(y \mid \theta)\, d \theta}} \]

  • Posterior: Belief of parameters after seeing the data
  • Likelihood: How likely the observed data is, given the parameters
  • Prior: What we think before seeing the data
  • “Normalizing constant”

Bayes: Why

  • Prior knowledge
  • Quantifies uncertainty
  • Transparent and explainable models
  • Iterative modelling
  • Causal inference

Bayes: How

PyMC is a probabilistic programming library for Python that allows users to build Bayesian models with a simple Python API and fit them using Markov chain Monte Carlo (MCMC) methods.

Stan offers a probabilistic programming language for statistical modeling using Bayesian inference.

Interfaces for Python, Julia, R, and the Unix shell.

Korkeasaari

Daily visitors counts since 2010 1

Hourly rainfall and temperature 2

Data

Questions

Q1: How much does rain affect the visitor counts?

Q2: Was there a tiger cub hype?

Hello PyMC

Questions answered

Q1: How much does rain affect the visitor counts?

Rain: effect

Rain: cumulative effect

Questions answered

Q2: Was there a tiger cub hype?

Tiger baby hype

Tiger baby hype: cumulative effect