DATA MINING
Desktop Survival Guide by Graham Williams |
|||||
Iris |
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"]) |