Database Reference
In-Depth Information
or
no
referring to the
Play
action of whether to play outside. Note that, by default,
R has converted the values of
Wind
(
True/False
) into numbers.
rpart.plot(fit, type=4, extra=1)
Figure 7.9
A decision tree built from DTdata.csv
The decisions in
Figure 7.9
are abbreviated. Use the following command to spell
out the full names and display the classification rate at each node.
rpart.plot(fit, type=4, extra=2, clip.right.labs=FALSE,
varlen=0, faclen=0)
The decision tree can be used to predict outcomes for new datasets. Consider a
testing set that contains the following record.
Outlook="rainy", Temperature="mild", Humidity="high",
Wind=FALSE
The goal is to predict the play decision of this record. The following code loads the
data into R as a data frame
newdata
. Note that the training set does not contain
this case.
newdata <- data.frame(Outlook="rainy", Temperature="mild",
Humidity="high", Wind=FALSE)
newdata
Outlook Temperature Humidity Wind
1 rainy mild high FALSE