[英]How to get the decision tree built at an iteration of the Ada boosting package in R?
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"? 我已经在R中使用“ ada”包构建了具有50个决策树的提升模型。如何打印在“ 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? 我可以使用“打印”功能显示“ rpart”对象的详细信息,是否有任何类似的功能可以打印内置在“ ada”对象中的决策树?
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))
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
. 树存储在列表中model$model$trees
这些是rpart
对象,因此您可以使用print
, plot
等,就像调用rpart
。
So, for instance to plot the 5th tree: 因此,例如绘制第5棵树:
plot(model$model$trees[[5]])
text(model$model$trees[[5]])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.