6.2 The bikes model, Bambi’s version
The first model we are going to use to illustrate how to use Bambi is the bikes model from Chapter 4. We can load the data with:
Code 6.8
bikes = pd.read_csv("data/bikes.csv")
Now we can build and fit the model:
Code 6.9
model_t = bmb.Model("rented ∼ temperature", bikes, family="negativebinomial")Â
idata_t = model_t.fit()
Figure 6.2 shows a visual representation of the model. If you want to visually inspect the priors, you can use model.plot_priors()
:
Figure 6.2: A visual representation of the bikes model, computed with the command model.graph()
Let’s now plot the posterior mean and the posterior predictive distribution (predictions). Omitting some details needed to make the plots look nice, the code to do this is:
Code 6.10
_, axes = plt.subplots(1, 2, sharey=True, figsize=(12, 4))Â
bmb.interpret.plot_predictions(model_t, idata_t,Â
   ...