Visualizing a conditional inference tree
Similar to rpart
, the party
package also provides a visualization method for users to plot conditional inference trees. In the following recipe, we will introduce how to use the plot
function to visualize conditional inference trees.
Getting ready
You need to have the first recipe completed by generating the conditional inference tree model, ctree.model
. In addition to this, you need to have both trainset
and testset
loaded in an R session.
How to do it...
Perform the following steps to visualize the conditional inference tree:
- Use the
plot
function to plotctree.model
built in the last recipe:
> plot(ctree.model)
A conditional inference tree of churn data
- To obtain a simple conditional inference tree, one can reduce the built model with less input features and redraw the classification tree:
> daycharge.model = ctree(churn ~ total_day_charge, data = trainset)> plot(daycharge.model)
A conditional inference tree using the total_day_charge
variable...