Reporting Bayesian results

Bayesian Data Analysis in Python

Michal Oleszak

Machine Learning Engineer

The honest way

  • Report the prior and the posterior of each parameter
posterior_draws
array([8.02800413, 8.97359548, 7.57437476, ..., 5.85264609, 7.92875104,
       7.41463758])
  • Plot prior and posterior distributions
sns.kdeplot(prior_draws, shade=True, label="prior")
sns.kdeplot(posterior_draws, shade=True, label="posterior")
Bayesian Data Analysis in Python

The honest way

Two density plots overlaid onto each other. Both are bell-shaped. Prior is centered at 0. short and wide, posterior is centered around 7 and is much taller and narrower.

Bayesian Data Analysis in Python

The honest way

Two density plots overlaid onto each other. Both are bell-shaped. Prior is centered at 0. short and wide, posterior is centered around 7 and is much taller and narrower.

Bayesian Data Analysis in Python

The honest way

Two density plots overlaid onto each other. Both are bell-shaped. Prior is centered at 0. short and wide, posterior is centered around 7 and is much taller and narrower.

Bayesian Data Analysis in Python

The honest way

Two density plots overlaid onto each other. Both are bell-shaped. Prior is centered at 0. short and wide, posterior is centered around 7 and is much taller and narrower.

Bayesian Data Analysis in Python

Bayesian point estimates

  • No single number can fully convey the complete information contained in a distribution

  • However, sometimes a point estimate of a parameter is needed

A bell-shaped density plot.

Bayesian Data Analysis in Python

Bayesian point estimates

  • No single number can fully convey the complete information contained in a distribution

  • However, sometimes a point estimate of a parameter is needed

posterior_mean = np.mean(posterior_draws)


A bell-shaped density plot with a vertical line marking its mean.

Bayesian Data Analysis in Python

Bayesian point estimates

  • No single number can fully convey the complete information contained in a distribution

  • However, sometimes a point estimate of a parameter is needed

posterior_mean = np.mean(posterior_draws)
posterior_median = np.median(posterior_draws)

A bell-shaped density plot with a vertical line marking its median.

Bayesian Data Analysis in Python

Bayesian point estimates

  • No single number can fully convey the complete information contained in a distribution

  • However, sometimes a point estimate of a parameter is needed

posterior_mean = np.mean(posterior_draws)
posterior_median = np.median(posterior_draws)
posterior_p75 = np.percentile(posterior_draws, 75)

A bell-shaped density plot with a vertical line marking its 75th percentile.

Bayesian Data Analysis in Python

Credible intervals

  • Such an interval that the probability that the parameter falls inside it is x%
  • The wider the credible interval, the more uncertainty in parameter estimate
  • Parameter is random, so it can fall into an interval with some probability
  • In the frequentist world, the (confidence) interval is random while the parameter is fixed

A bell-shaped density plot with two dashed vertical lines marking the region between them.

Bayesian Data Analysis in Python

Highest Posterior Density (HPD)

A GIF of a bell-shaped density plot showing a horizontal line descending down the plot area, resulting in an increasing are of the probability mass located between the points, where the line intersects with the plot.

import arviz as az

hpd = az.hdi(posterior_draws, 
             hdi_prob=0.9)
print(hpd)
[-4.86840193  4.96075498]
Bayesian Data Analysis in Python

Let's practice reporting Bayesian results!

Bayesian Data Analysis in Python

Preparing Video For Download...