Bike share forecast for upcoming Thanksgiving weekend
In case you plan to get around and explore Vancouver by renting a bike on this Thanksgiving weekend, I built some predictive models to forecast number of bikes that are going to be rented each hour on this long weekend. The bike share program is operated by Mobi by Shaw Go and historical bike rental data is hosted on their website.
Original article can be found on my blog and Python code on my GitHub.
Here is a quick summary of the workflow.
A little preview of the predictions for last week of July 2018.
Because we don't have actual bike rentals for the upcoming weekend, here are only the predictions.
Summarized in a table:
Data Gathering
Data is collected from three different sources:
- Historical bike rental data from Mobi website
- Statutory holidays: OfficeHolidays
- Weather information from Air Data Archive by BC Government
Exploratory Analysis
Correlation with other variables.
- Hour of day. It seems the early evening hours have the greatest demand for bike shares. Could it be an indication of riding bikes for social activities? Like going to restaurants, hanging out with friends, going to gyms, etc.
- Holidays. Out of 10 BC statutory holidays, only 4 had more bike rides than a normal day average. Not surprisingly, all 4 had above-average day temperature.
- Temperature. The line plot of daily bike rentals and temperature clearly shows temperature has a big impact on riding bikes. The correlation of the two (from the heatmap) is 0.71, a strong positive correlation (1.0 for perfect correlation and 0.0 means no correlation).
- Precipitation. The correlation value is -0.17, meaning precipitation slightly and negatively impacts riding bikes. It is understandable that no one likes to bike in a rain or snow. But, this is Vancouver (or Raincouver). People do not mind a little rain and they would still bike, run, and play outside. So, rain negatively affects bike riding but not so significantly.
- PM2.5 (air quality). In general air quality is excellent in the city. There are days that we had hazy skies due to crazy inland wildfires, but very few. So, the heatmap does not show any correlationship of PM2.5 with bike ride.
More data analysis can be found on my blog post.
Model Training
Training dataset contains hourly bike rentals for each day from 01/01/2017 to 07/24/2018.
Two decision tree models were trained: Random Forest (RF) and Gradient Boosted Trees (GBM). They are well known for delivering better performance and efficiency on noisy datasets. However, tuning hyperparameters can be some challenges so that they will not overfit
Evaluation on Test
Test is done on hourly bike rentals from 07/25/2018 to 07/31/2018. Graph below shows our predictions are very close to real number of bikes rented. YAY!!
There you go! We will see how far/close the forecasts of bike shares on the long weekend will be. Just noticed the grand Vancouver Halloween parade is going to be on this weekend, which is one week earlier than it was before. That could hugely impact the result. Nevertheless, it will be fun to watch.
Happy Thanksgiving!
Original article can be found on my blog and Python code on my GitHub.
Business Development Director @ RSM Canada
6 年Very cool Peng Wang, CPA, CMA, I'm sure the folks at Citi Bike, Operated by Motivate?would be interested in their predicted peak times?
Engineering Leader | Volunteer Board Director | Community Builder
6 年Vancouver Bike Share - DBA "Mobi by Shaw Go"