Get startedGet started for free

Visualize the xgboost bike rental model

You've now seen three different ways to model the bike rental data. For this example, you've seen that the gradient boosting model had the smallest RMSE. To finish up the course, let's compare the gradient boosting model's predictions to the other two models as a function of time.

On completing this exercise, you will have completed the course. Congratulations! Now you have the tools to apply a variety of approaches to your regression tasks.

The data frame bikesAugust with predictions,has been pre-loaded. The plots quasipoisson_plot and randomforest_plot are also available.

This exercise is part of the course

Supervised Learning in R: Regression

View Course

Exercise instructions

  • Print quasipoisson_plot to review the quasipoisson model's behavior.
  • Print randomforest_plot to review the random forest model's behavior.
  • Fill in the blanks to plot the gradient boosting predictions and actual counts by hour for the first 14 days of August.
    • pivot_longer() the cnt and gbm column names into a column called value, with a key called valuetype.
    • Plot value as a function of instant (day).

How does the gradient boosting model compare to the previous models?

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Print quasipoisson_plot
___

# Print randomforest_plot
___

# Plot predictions and actual bike rentals as a function of time (days)
bikesAugust %>% 
  mutate(instant = (instant - min(instant))/24) %>%  # set start to 0, convert unit to days
  filter(instant < 14) %>% # first two weeks
  pivot_longer(c(___, ___), names_to = ___, values_to = ___) %>%
  ggplot(aes(x = ___, y = ___, color = valuetype, linetype = valuetype)) + 
  geom_point() + 
  geom_line() + 
  scale_x_continuous("Day", breaks = 0:14, labels = 0:14) + 
  scale_color_brewer(palette = "Dark2") + 
  ggtitle("Predicted August bike rentals, Gradient Boosting model")
Edit and Run Code