Exercise

Create bagged trees

Ensemble models like bagged trees are more powerful than single decision trees. Each tree in the ensemble gives a vote, and the average or majority vote is your prediction. This ensures you use swarm intelligence instead of relying on a single tree. For bagged trees, the bootstrap method ensures that in every ensemble tree, only a bootstrapped sample (sampled with replacement) of the original dataset is used to train the tree and create the prediction.

Put this into practice by building a bagged classification tree yourself!

The credit card customers training data is pre-loaded as customers_train.

Instructions 1/3

undefined XP
    1
    2
    3
  • Use bag_tree() to create a bagged tree classification model with an "rpart" engine that builds 20 bagged trees.