Grow a simple decision tree to predict whether a passenger survived using Age as an independent variable and then plot the tree:
library(rpart) library(rpart.plot) set.seed(123) fit <- rpart(as.factor(Survived) ~ Age, data=titanic, method="class") rpart.plot(fit,extra=102)
How accurate was this simple tree? Just to flex our brain, we will compute this manually.
At the console, compute the correct classification percentages. The correct number of predictions for each class is shown as the first number in each node in the preceding plot. The second number is the total number assigned to that class.
By adding up the total ...