O'Reilly logo

Practical Predictive Analytics by Ralph Winters

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

An age decision tree

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required