LoslegenKostenlos loslegen

Predict bike rentals on new data

In this exercise, you will use the model you built in the previous exercise to make predictions for the month of August. The dataset bikesAugust has the same columns as bikesJuly.

Recall that you must specify type = "response" with predict() (docs) when predicting counts from a glm poisson or quasipoisson model.

The model bike_model and the bikesAugust data frame have been pre-loaded.

Diese Übung ist Teil des Kurses

Supervised Learning in R: Regression

Kurs anzeigen

Anleitung zur Übung

  • Use predict to predict the number of bikes per hour on the bikesAugust data. Assign the predictions to the column bikesAugust$pred.
  • Fill in the blanks to get the RMSE of the predictions on the August data.
  • Fill in the blanks to generate the plot of predictions to actual counts.
    • Do any of the predictions appear negative?

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# bikesAugust is available
str(bikesAugust)

# bike_model is available
summary(bike_model)

# Make predictions on August data
bikesAugust$pred  <- ___

# Calculate the RMSE
bikesAugust %>% 
  mutate(residual = ___) %>%
  summarize(rmse  = ___)

# Plot predictions vs cnt (pred on x-axis)
ggplot(bikesAugust, aes(x = ___, y = ___)) +
  geom_point() + 
  geom_abline(color = "darkblue")
Code bearbeiten und ausführen