Get startedGet started for free

Sampling posterior draws

Tired of working for the central government and for the marketing company, you take a new job as a data analyst for your city's local authorities. The city operates a bike-sharing system in the city and they ask you to predict the number of bikes rented per day to plan staff and repairs accordingly.

You have been given some data on the number of rented vehicles per day, temperature, humidity, wind speed, and whether the day was a working day:

     work_day      temp  humidity  wind_speed  num_bikes
0           0  0.344167  0.805833    0.160446      0.985
1           0  0.363478  0.696087    0.248539      0.801
..        ...       ...       ...         ...        ...
698         1  0.280870  0.555652    0.115522      5.323
699         1  0.298333  0.649583    0.058471      5.668

Try building a regression model to predict num_bikes using the bikes DataFrame and pymc3 (aliased as pm).

NOTE: Calling pm.sample() for the first time in a fresh Python session takes some time, as Python code is being compiled to C under the hood. To save you time, we only ask you to get the code right instead of executing it.

This exercise is part of the course

Bayesian Data Analysis in Python

View Course

Hands-on interactive exercise

Turn theory into action with one of our interactive exercises

Start Exercise