简体   繁体   中英

Can I store ctree splitting rules and terminal nodes plots in a table?

I would like to create a table to summarise the splitting rules of a conditional inference tree (ctree) so that each predictor is in a separate column and each row is a terminal node with corresponding values from each of the predictors. For example:

IrisTree <- ctree(Species ~ ., data = iris)

which results in this tree:

虹膜数据上的 ctree

and store the results in a way such as below:

汇总表

Also, I would like to embed in a last column each of the plots resulting at terminal nodes, but I am struggling to find a way to store plots separately. Is it possible?

Split rules

The split summary can be built on the (still unexported) function .list.rules.party() :

partykit:::.list.rules.party(IrisTree)
##                                                               2 
##                                           "Petal.Length <= 1.9" 
##                                                               5 
## "Petal.Length > 1.9 & Petal.Width <= 1.7 & Petal.Length <= 4.8" 
##                                                               6 
##  "Petal.Length > 1.9 & Petal.Width <= 1.7 & Petal.Length > 4.8" 
##                                                               7 
##                        "Petal.Length > 1.9 & Petal.Width > 1.7" 

For further processing of split summaries, see also the following answers:

Plotting subtrees

The individual plots can be easily obtained by subsetting the tree suitably. In general if tree is a party object, then tree[i] is the party object rooted in Node i . These can still be plotted as before.

Thus, when selecting and plotting only a terminal node, this gives you the panel from that terminal node:

plot(IrisTree[5])

鸢尾树的终端节点 5

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM