Predict bike rentals with the random forest model
In this exercise, you will use the model that you fit in the previous exercise to predict bike rentals for the month of August.
The predict() (docs) function for a ranger model produces a
list. One of the elements of this list is predictions, a vector of predicted values. You can access predictions with the $ notation for accessing named elements of a list:
predict(model, data)$predictions
The model bike_model_rf and the dataset bikesAugust (for evaluation) have been pre-loaded.
Este exercício faz parte do curso
Supervised Learning in R: Regression
Instruções do exercício
- Call predict()onbikesAugustto predict the number of bikes rented in August (cnt). Add the predictions tobikesAugustas the columnpred.
- Fill in the blanks to calculate the root mean squared error of the predictions.- The poisson model you built for this data gave an RMSE of about 112.6. How does this model compare?
 
- Fill in the blanks to plot actual bike rental counts (cnt) versus the predictions (predon x-axis).
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# bikesAugust is available
str(bikesAugust)
# bike_model_rf is available
bike_model_rf
# Make predictions on the August data
bikesAugust$pred <- ___(___, ___)$___
# Calculate the RMSE of the predictions
bikesAugust %>% 
  mutate(residual = ___)  %>% # calculate the residual
  summarize(rmse  = ___)      # calculate rmse
# Plot actual outcome vs predictions (predictions on x-axis)
ggplot(bikesAugust, aes(x = ___, y = ___)) + 
  geom_point() + 
  geom_abline()