【问题标题】:How to get the decision tree built at an iteration of the Ada boosting package in R?如何在 R 中的 Ada boosting 包的迭代中构建决策树?
【发布时间】:2015-08-12 06:58:20
【问题描述】:

我使用 R 中的“ada”包构建了一个包含 50 个决策树的提升模型。如何打印在“ada”迭代中构建的决策树?

我可以使用“打印”功能来显示“rpart”对象的详细信息,有没有类似的功能可以打印“ada”对象中构建的决策树?

非常感谢!

我的示例代码如下:

    library(ada)
    data("soldat")
    model <- ada(y ~ .
               , data=soldat
               , loss="e"
               , type="discrete"
               , iter=50
               , control=rpart.control(cp=-1, maxdepth=2))

【问题讨论】:

  • 你能展示一些代码吗,也许是一个可重现的例子?

标签: r printing boosting


【解决方案1】:

树存储在列表model$model$trees 这些是rpart 对象,因此您可以使用print、plot 等,就像调用rpart 时一样。

因此,例如绘制第 5 棵树:

plot(model$model$trees[[5]])
text(model$model$trees[[5]])

【讨论】:

    猜你喜欢
    • 2017-05-02
    • 2021-03-02
    • 2014-05-09
    • 2016-05-18
    • 2014-08-21
    • 2021-12-22
    • 2016-07-27
    • 2014-12-11
    • 2015-06-28
    相关资源
    最近更新 更多