# Rattle: Data Mining by Example # # Copyright (c) 2011 Graham.Williams@togaware.com # # Common decision tree using rpart(). source("datasets.R") MODEL <- new.env(parent=weatherDS) evalq({ require(rpart) build.time <- system.time(model <- rpart(formula=form, data=data[train, vars])) pr <- predict(model, data[test, vars], type="prob")[,2] cl <- predict(model, data[test, vars], type="class") }, MODEL) MODEL$model MODEL$build.time save(MODEL, file="rpart01.Rdata") rattle.print.rpart(MODEL$model) drawTreeNodes(MODEL$model) title(main="Decision Tree rpart() weather $ RainTomorrow", sub=paste("Rattle", format(Sys.time(), "%Y-%b-%d %H:%M:%S"), Sys.info()["user"]))