0

I have built a boosting model with 50 decision trees using the "ada" package in R. How can I print the decision tree built at a iteration of "ada"?

I can use the "print" function to display the detail of a "rpart" object, is there any similar function to print the decision trees built in an "ada" object?

Thank you very much!

My sample code is like below:

    library(ada)
    data("soldat")
    model <- ada(y ~ .
               , data=soldat
               , loss="e"
               , type="discrete"
               , iter=50
               , control=rpart.control(cp=-1, maxdepth=2))
Simon Wright
  • 25,108
  • 2
  • 35
  • 62
Carter
  • 1,563
  • 8
  • 23
  • 32

1 Answers1

2

The trees are stored in the list model$model$trees These are rpart objects so you can use print, plot etc., just as when calling rpart.

So, for instance to plot the 5th tree:

plot(model$model$trees[[5]])
text(model$model$trees[[5]])
nico
  • 50,859
  • 17
  • 87
  • 112