Taxi Tip Predictor App

  • Purpose of the 'Taxi Tip Predictor App' is to allow the user to change variable values in the interface and then plot / return the estimated tips that a taxi driver could expect per mile in different community areas around Chicago.
  • Underneath the interface is a linear regression model which has been evolved from Chicago taxi data found on Kaggle.
  • Prediction model is then joined by way of the shiny app interface so users can pass variable values to return prediction values (ie: What tips they can expect from the fare parameters they pass to the app).
  • Link to the ui.R file here:
  • Link to the server.R file here:

Inputs

Variables which can be modified / passed by the user

  • 1: Miles of fare
  • 2: Payment Type
  • 3: Time of the Fare (closest hour)
  • 4: Fare Amount
  • 5: Day of the Week

Variables mapped over the app interface can be seen here:

Outputs and Model

Outputs Once the user is happy with the variable values, they press the 'Prediction' button and then

  • A geographical map of the 8 community areas considered appears / updates with coloured circles (as markers) appearing to denote the level of expected tips based on the variable values passed.
  • Table under the map is generated depicting the 8 community areas and the expected tips per mile values.

Model Linear model evolved from the Chicago Taxi data set, next slide presents an R code example executed against the prediction model using the predict() function and returning an estimated tips per mile figure.

Example: Passing values to the predict() function

eg_hour<-'13'
eg_fare <- 90
eg_day <- 'Saturday'
eg_miles <- 18
eg_community <- '24'
eg_payment <- 'Cash'
les_test1<-data.frame(as.factor(eg_hour),as.numeric(eg_fare),as.factor(eg_day),as.factor(eg_payment),as.factor(eg_community),as.numeric(eg_miles))
names(les_test1)<-c('hour','fare','day_of_week','payment_type','pickup_community_area','trip_miles')
predict(model,les_test1)
       1 
6.638269 

What happens in the App?

  • Users adjust input values by way of widgets in the app interface.
  • When they are ready to display the predicted tips per mile for each community area they press the 'PRESS to Plot the Prediction' button (once pressed, inputed values are passed to a linear regression model (built on historical data) by way of the predict() function to the r server instance where calculations are performed, because the prediction is computed each time, potentially as prediction models evolve / change, the user can still interact with the same familiar app interface while the underlying complexity has the flexibility to change and get re run each time.)
  • A geospatial plot renders returning the predict() fucntion results for 8 community areas around Chicago (expected tips per community area). A supporting table also appears displaying the names of each community area and predicted tips per mile value.