In the partykit package print(i.ctree) provides the probability of the outcome at terminal nodes (classification tree). However, I would like to know the probability of the outcome at internal nodes as well.
I'm able to estimate the probability at the internal nodes when I create a barplot for my ctree plot(i.ctree, inner_panel = node_barplot). But what I would like is the exact probability at internal nodes. For example, in the diagram below I would like to know the probability of the outcome at nodes 2 and 5.
Any ideas?
Using an example from https://cran.r-project.org/web/packages/partykit/vignettes/ctree.pdf:
barplot of ctree:

There are various ways to extract the full data pertaining to a certain node and compute any quantity you are interested in. For the distribution of a classification tree one way is to coerce to the
simplepartyclass which stores thedistributionin theinfoslots of each node.Using the example from the vignette you mentioned, you can first fit the full
constpartytree:And then coerce to
simpleparty:Then you can extract a list of distributions from each node, bind it into a table, and compute the proportions:
You can also adapt the panel function for the printing, re-using the functions used in
print.simpleparty: