Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data = iris
- head(data)
- sampler = sample(1:nrow(data), size = 0.9*nrow(data), replace = FALSE)
- training_data = data[sampler,]
- testing_data = data[-sampler,]
- # test_data_label = testing_data[,5]
- # training_data_label = training_data[,5]
- #
- # test_data = testing_data[,-5]
- # training_data = training_data[,-5]
- library(rattle)
- library(rpart)
- library(rpart.plot)
- model = rpart(training_data$Species~., data=training_data, minsplit=2)
- fancyRpartPlot(model)
- prediction = predict(model, testing_data[,-5])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement