Download Plotting rpart trees with prp

Transcript
1
Introduction
The prp function plots rpart trees [6, 7]. It automatically scales and adjusts the displayed tree for best fit.
It combines and extends the plot.rpart and text.rpart functions in the rpart package. Figure 1 below
shows some examples. The function is in the rpart.plot R package.
Note that rpart.plot is merely a front end to prp, with the most useful arguments of prp.
Section 2 of this document (the Overview) is the most important. The remaining sections may be skipped
or read in any order.
I assume you have already looked at the vignette included with the rpart package [7]:
An Introduction to Recursive Partitioning Using the RPART Routines by Therneau and Atkinson.
default prp
(type = 0)
type = 4, extra = 6
died
0.38
sex=mal
yes
no
sex=mal
fml
age>=9.5
died
0.19
survived
survived
0.73
age>=9.5
<9.5
sibsp>=2.5
died
died
0.17
survived
0.53
sibsp>=2.5
<2.5
died
survived
died
0.05
assorted arguments
survived
0.89
plot.rpart for comparison
sex=b
|
1
yes is sex = male?
no
age>=9.5
survived
1e+02/3e+02
2
is age >= 9.5?
sibsp>=2.5
died
7e+02/1e+02
5
is sibsp >= 2.5?
4
10
11
3
died
0.17 61%
died
0.05 2%
survived
0.89 2%
survived
0.73 36%
died
2e+01/1
survived
3/2e+01
Figure 1: Some prp examples, with a plot.rpart graph for comparison. The data is the Titanic data with
survival as the response (sibsp is the number of siblings or spouses aboard).
2