Skip to content

Commit 0a78e50

Browse files
Naive Bayes model with calculated accuracy
1 parent d970f25 commit 0a78e50

File tree

1 file changed

+14
-0
lines changed
  • Part 7 - Natural Language Processing

1 file changed

+14
-0
lines changed

Part 7 - Natural Language Processing/NLP.R

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,18 @@ cm_svm = table(test_set[, 692], y_pred_svm)
136136

137137
# Accuracy (Support Vector Machine) = (78+81)/(78+81+22+19) = 0.795
138138

139+
# Naive Bayes
140+
141+
library(e1071)
142+
143+
classifier_nb = naiveBayes(x = training_set[-692], #independent variables
144+
y = training_set$Liked) #dependent variable
145+
146+
# Predicting the Test set results
147+
y_pred_nb = predict(classifier_nb, newdata = test_set[-692])
148+
149+
# Making the Confusion Matrix
150+
cm_nb = table(test_set[, 692], y_pred_nb)
151+
152+
# Accuracy (Naive Bayes) = (5+96)/200 = 0.505
139153

0 commit comments

Comments
 (0)