ComenzarEmpieza gratis

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 ejercicio forma parte del curso

Supervised Learning in R: Regression

Ver curso

Instrucciones del ejercicio

  • 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.

Ejercicio interactivo práctico

Prueba este ejercicio completando el código de muestra.

# 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
___
Editar y ejecutar código