Created
November 28, 2018 21:09
-
-
Save JakubMifek/f2c19c05372230e67d8c2fd8ca14eb07 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
attach(train) | |
m.tree <- rpart(mpg01 ~ ., train) | |
rpart.plot(m.tree) | |
prediction.m.tree <- predict(m.tree, test, type="class") | |
table(prediction.m.tree) | |
m.tree.cm <- table(prediction.m.tree, test$mpg01) | |
m.tree.cm | |
message("Accuracy = ", sum(diag(m.tree.cm))/78) | |
M.deep <- rpart(mpg01 ~ ., train, cp=0.000001) | |
rpart.plot(M.deep) | |
printcp(M.deep) | |
plotcp(M.deep) | |
prediction.M.deep <- predict(M.deep, test, type="class") | |
table(prediction.M.deep) | |
M.deep.cm = table(prediction.M.deep, test$mpg01) | |
M.deep.cm | |
message("Accuracy = ", sum(diag(M.deep.cm))/78) | |
M.best <- rpart(mpg01 ~ ., train, cp=0.018) | |
rpart.plot(M.best) | |
printcp(M.best) | |
plotcp(M.best) | |
prediction.M.best <- predict(M.best, test, type="class") | |
table(prediction.M.best) | |
M.best.cm = table(prediction.M.best, test$mpg01) | |
M.best.cm | |
message("Accuracy = ", sum(diag(M.best.cm))/78) | |
detach(train) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment