ComeçarComece de graça

Predictive distribution

Good job analyzing the parameter draws! Let's now use the linear regression model to make predictions. How many clicks can we expect if we decide to show 10 clothes ads and 10 sneaker ads? To find out, you will have to draw from the predictive distribution: a normal distribution with the mean defined by the linear regression formula and standard deviation estimated by the model.

First, you will summarize each parameter's posterior with its mean. Then, you will calculate the mean of the predictive distribution according to the regression equation. Next, you will draw a sample from the predictive distribution and finally, you will plot its density. Here is the regression formula for your convenience:

The number of clicks has a normal distribution with the mean β0 + β1 * clothes-ads-shown + β2 * sneakers-ads-shown, and some standard deviation sigma.

pymc3, numpy, and seaborn have been imported under their usual aliases.

Este exercício faz parte do curso

Bayesian Data Analysis in Python

Ver curso

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# Aggregate posteriors of the parameters to point estimates
intercept_coef = ____
sneakers_coef = ____
clothes_coef = ____
sd_coef = ____
Editar e executar o código