ctree() - 当响应变量为分类变量时,如何获取每个终端节点的拆分条件列表

时间:2016-01-25 05:50:32

标签: r classification decision-tree party

用于重现错误以及我打算获得的内容。我有以下示例。 假设我有一个数据集:Iris。我正在使用

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

enter image description here

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

我发现了

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

很容易找到分裂条件。但是我的数据集需要8个多小时才能将树的maxdepth定义为3。

总结:

  1. 我需要使用library(party)
  2. 找到树的拆分条件
  3. 还可以在树的终端节点中找到值。所以我可以在定义规则时使用这些值
  4. *注意:我的数据集比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"’
    

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

0 个答案:

没有答案