Skip to content

Example: Bike Prediction#

Bike predict workflow diagram

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.

Background#

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.

Goal#

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 Description Code Content Deployed to Connect
ETL - Step 1 - Raw Data Refresh Get the latest station status data from the https://capitalbikeshare.com API. The data is written to Content DB in table bike_raw_data and bike_station_info. content/01-etl/01-raw-data-refresh/document.qmd Quarto document, Pin
ETL - Step 2 - Tidy Data From Content DB get two tables: (1) bike_raw_data and (2) bike_station_info. The two data sets are tidied and then combined. The resulting tidy data set is written to Content DB in table bike_model_data. content/01-etl/02-tidy-data/document.qmd Quarto document
Model - Step 1 - Train and Deploy Model From Content DB get the bike_model_data table and then train a model. The model is saved to Connect as a pin, and then deployed to Connect as a plumber API using vetiver. content/02-model/01-train-and-deploy-model/document.qmd Quarto document, Pin, Plumber API
Model - Step 2 - Model Card Use the vetiver model card template to document essential facts and considerations of the deployed model. content/02-model/02-model-card/document.qmd Quarto document
Model - Step 3 - Model Metrics Use functions provided by vetiver to document model performance. Model performance metrics are written to a pin on RStudio Connect. content/02-model/03-model-metrics/document.qmd Quarto document, Pin
App - Client App (DEV) A development version of the client app. content/03-app/03-client-app-dev/app.R Shiny app
App - Client App Use the API endpoint to interactively server predictions to a shiny app. content/03-app/01-client-app/app.R Shiny app
App - Dashboard A connect widgets dashboard containing links to all of the bike predict content. content/03-app/02-connect-widgets-app/document.qmd Quarto document
Package - bikeHelpR An R package to support the Bike Prediction project. https://github.com/sol-eng/bikeHelpR RStudio Package Manager