Skip to content

Instantly share code, notes, and snippets.

@BenHeubl
Created February 13, 2020 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BenHeubl/f7ba8d25e2f04600f998ab5c65a560f5 to your computer and use it in GitHub Desktop.
Save BenHeubl/f7ba8d25e2f04600f998ab5c65a560f5 to your computer and use it in GitHub Desktop.
tut19
install.packages("rpart")
install.packages("caret")
install.packages("e1071")
library(rpart)
library(caret)
library(e1071)
model_decision_tree = train(INCOME ~ ., data = TrainSet, method = "rpart")
model_decision_tree_prediction = predict(model_decision_tree, data = TrainSet)
table(model_decision_tree_prediction, TrainSet$INCOME)
mean(model_decision_tree_prediction == TrainSet$INCOME)
#[1] 0.7341071
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment