Skip to content

Example: Bike Prediction#

This app provides real-time predictions of the number of bikes that will be available at the stations of Washington DC's docked bike share, Capital Bikeshare. Creating and visualizing those predictions takes advantage of many different types of R content and the ability to deploy them on RStudio Connect.


Like many metropolitan areas, the Washington DC area has bicycles available for short-term rental to commuters and tourists at docks around the city. The number of bikes at each of these docks ebbs and flows throughout the day, and the Capital Bikeshare program provides real-time data on the number of bikes available at each dock via an API.


The goal of this app is to provide a prediction of the number of bikes at a station in the near future based on real-time streaming data from an API. These predictions will be made available in a web application and to other services via an API. Furthermore, continuous monitoring of the predictions will be enabled to watch for model drift and changes in goodness-of-fit over time.

The source code and more detail on this project can be found on the Github Repository.

Here are links to all the content in the project

Content Content Description Code Pin Refresh Frequency
Raw Data Ingest Script Writes data from API calls into bike_raw_data table in postgres. Code NA Every 20 Minutes
Clean Data Script Cleans bike_raw_data for modeling, writes into bike_model_data. Code NA Daily (4 am)
Clean Station Metadata Script Ingests station metadata and saves to a pin (names, lat/long). Code bike_station_info Weekly (Sundays)
Data Split Script Creates a training/test split for the data for models to use, saves to a pin. Code bike_model_params Daily (5 am)
R XGB Model Train Retrains model based on training/test split indicated by Data Split Script, writes into pin. Code bike_rxgb Daily (6 am)
Model Metrics Script Writes bike_test_data and bike_predictions postgres tables, writes pin of goodness-of-fit metrics. Code bike_err_dat Daily (8 am)
Model Performance App Displays model performance metrics. Code NA NA
Model API Serves model predictions via Plumber API. Code NA NA
Bike Prediction App Displays predictions from App. Code NA NA
Dev Bike Prediction App Dev version of Bike Prediction App Code NA NA
bikeHelpR Package An R package of helper functions, built in internal repo on Code NA Tags