What should be the value of control argument in bagging model?



I am currently trying to implement the bagging model in R and while searching about it I have found the formula of bagging model

bagging(formula, data, mfinal , control)

There are four attributes in the model

  1. Formula
  2. Data
  3. mfinal
  4. control

as in the lm function.

a data frame, help to interpret the variables named in the formula

an integer, the number of iterations for which boosting is run or the number of trees to use. Defaults to mfinal=100 iterations.

controls details of the rpart algorithm.

I have fairly understood the first three arguments but not able to understand the control argument and how it’s value affects the model performance.



It basically controls those arguments value which is needed in designing of rpart algorithm
you can check the documentation of rpart.control for better understanding.

Hope this helps!



Hi Harry,

You can use the caret package and see the documentation here for bagged trees: http://topepo.github.io/caret/Bagging.html

The control can be things like k-fold cross-validation, repeated k-fold cross validation, leave-one-out cross-validation , …

example: with repeated k-fold cross-validation, setting k=10 and repeating it 5 times,

control <- trainControl(method=“repeatedcv”, number=10, repeats=5)

my_bagged_cart <- train(X, y
method = “treebag”,
preProc = c(“center”, “scale”),
trControl = control)

The “applied predictive modeling” book by the creator of the caret package shows how to implement the different machine learning techniques in R.