Desktop Survival Guide
by Graham Williams


There are many datasets available within R and its packages that are suitable for illustrating decision tree induction. We'll start with the iris dataset. See the R help on the iris dataset for details.

> train <- c(sample(nrow(iris), 0.5*nrow(iris)))
> i.rpart <- rpart(Species ~ ., data=iris[train,])
> i.rpart
> plot(i.rpart); text(i.rpart)
> table(predict(i.rpart, iris[-train,], type="class"), 
        iris[-train, "Species"])

Copyright © 2004-2010 Togaware Pty Ltd
Support further development through the purchase of the PDF version of the book.
The PDF version is a formatted comprehensive draft book (with over 800 pages).
Brought to you by Togaware. This page generated: Sunday, 22 August 2010