Predicting once you fit a model

Supervised Learning in R: Regression

Nina Zumel and John Mount

Win-Vector LLC

Predicting From the Training Data

cricket$prediction <- predict(cmodel)
  • predict() by default returns training data predictions
Supervised Learning in R: Regression

Looking at the Predictions

ggplot(cricket, aes(x = prediction, y = temperature)) + 
     geom_point() +
     geom_abline(color = "darkblue") + 
     ggtitle("temperature vs. linear model prediction")

Supervised Learning in R: Regression

Predicting on New Data

newchirps <- data.frame(chirps_per_sec = 16.5)
newchirps$prediction <- predict(cmodel, newdata = newchirps)
newchirps
   chirps_per_sec     pred
 1           16.5 79.53537

Supervised Learning in R: Regression

Let's practice!

Supervised Learning in R: Regression

Preparing Video For Download...