1

为了重现错误和我打算得到什么。我有以下示例。假设我有一个数据集:Iris。我正在使用建模分类树

library(party)
ct <- ctree(Species ~ ., data = iris) #here Species is the categorical response variable
print(ct)
plot(ct)

在此处输入图像描述

但我的问题是如何获得每个节点的拆分条件以及终端节点值?

我发现使用

library(partykit)
partykit:::.ctree_fit(ct)

很容易找到拆分条件。但是对于我的数据集来说,这需要 8 个多小时,其中树的最大深度定义为 3。

总结一下:

  1. 我需要找到一棵树的分裂条件library(party)
  2. 还可以在树的终端节点中找到值。所以我可以在定义规则时使用这些值

*注意:我的数据集比 Iris 数据集稍微复杂一点。我有以下结构

ct <- ctree(Y ~ V1 + V2 + V3 ,  data= MyData,controls = ctree_control(maxdepth = 3))# here Y is factor variable , V1 & V3 is continous , V2 is categorical variable

当我这样做时:where(ct)我得到以下错误*错误:

Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘where’ for signature ‘"constparty"’

请帮助我进一步解决这个问题

4

0 回答 0