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