Session Ready
Exercise

Train a bagged tree model

Let's start by training a bagged tree model. You'll be using the bagging() function from the ipred package. The number of bagged trees can be specified using the nbagg parameter, but here we will use the default (25).

If we want to estimate the model's accuracy using the "out-of-bag" (OOB) samples, we can set the the coob parameter to TRUE. The OOB samples are the training obsevations that were not selected into the bootstrapped sample (used in training). Since these observations were not used in training, we can use them instead to evaluate the accuracy of the model (done automatically inside the bagging() function).

Instructions
100 XP
  • The credit_train and credit_test datasets from Chapter 1 are already loaded in the workspace.
  • Use the bagging() function to train a bagged tree model.
  • Inspect the model by printing it.