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 alternative decision tree

Let's say we arbitrarily selected another simple decision tree model; this time we will predict whether or not a passenger survived based upon the passenger class variable:

This is a slightly more complex tree, since it has four branches and three terminal nodes. Now, let's calculate the correct classification rate for the model by adding up the correct classification numbers for the three nodes and dividing this by the total number of rows, as we did before:

> (270+90+122) / nrow(titanic) 

This is the following output:

[1] 0.67507 > 

This simple model is even better, with a 67% correct classification.

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