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.
Este exercício faz parte do curso
Supervised Learning in R: Regression
Instruções do exercício
- Create a formula fmlathat expresses the relationshipctyas a function ofhwy. Print it.
- Train a model mpg_modelonmpg_trainto predictctyfromhwyusingfmlaandlm().
- Use summary()to examine the model.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# mpg_train is available
summary(mpg_train)
# Create a formula to express cty as a function of hwy: fmla and print it.
(fmla <- ___)
# Now use lm() to build a model mpg_model from mpg_train that predicts cty from hwy 
mpg_model <- ___
# Use summary() to examine the model
___