1. Learn
  2. /
  3. Courses
  4. /
  5. Supervised Learning in R: Regression

Exercise

Train a model using test/train split

Now that you have split the mpg dataset into mpg_train and mpg_test, you will use mpg_train to train a model to predict city fuel efficiency (cty) from highway fuel efficiency (hwy).

The mpg_train data frame has been loaded for you.

Instructions

100 XP
  • Create a formula fmla that expresses the relationship cty as a function of hwy. Print it.
  • Train a model mpg_model on mpg_train to predict cty from hwy using fmla and lm().
  • Use summary() to examine the model.