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:
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?
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:
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])
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.