From the last recipe, we learned how to print the classification tree in a text format. To make the tree more readable, we can use the plot
function to obtain the graphical display of a built classification tree.
One needs to have the previous recipe completed by generating a classification model, and assign the model into the churn.rp
variable.
Perform the following steps to visualize the classification tree:
Use the
plot
function and thetext
function to plot the classification tree:> plot(churn.rp, margin= 0.1) > text(churn.rp, all=TRUE, use.n = TRUE)
You can also specify the
uniform
,branch
, andmargin
parameter to adjust the layout:> plot(churn.rp, uniform=TRUE, branch=0.6, margin=0.1) > text(churn.rp, all=TRUE, use.n = TRUE)