Aan de slagGa gratis aan de slag

Predict new values

A predictive model is one that predicts the outcomes of new, unseen data. Besides the numeric predictors, there are other useful columns in the dataset. The goal of this exercise is to predict the final rating grades of a chocolate tasting based on all other predictor variables that are available.

Loaded in your workspace is the regression tree specification that you created in the last exercise, chocolate_spec, as well as the training and testing data (chocolate_train and chocolate_test).

Deze oefening maakt deel uit van de cursus

Machine Learning with Tree-Based Models in R

Cursus bekijken

Oefeninstructies

  • Use model_spec to train a regression tree chocolate_model that predicts final_grade using all predictors in the data.
  • Predict final_grade values using the chocolate_test tibble.
  • Add the results to the chocolate_test tibble.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Train the model
chocolate_model <- model_spec %>%
  ___

# Predict new data
predictions <- predict(___,
                       ___) %>%
  # Add the test set
  bind_cols(___)

predictions
Code bewerken en uitvoeren