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]
- model = naiveBayes(training_data, training_data_label)
- prediction = predict(model, test_data)
- library(caret)
- table(prediction, test_data_label)
- confusionMatrix(prediction, test_data_label)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement