Created
January 16, 2019 15:25
-
-
Save ashokc/baead23da3140974ff2fae31a33c85e2 to your computer and use it in GitHub Desktop.
Naive Bayes Implementation with SciKit
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
from sklearn.naive_bayes import MultinomialNB | |
model = MultinomialNB() | |
train_x = Xencoded[train_indices] | |
test_x = Xencoded[test_indices] | |
train_labels = labels[train_indices] | |
test_labels = labels[test_indices] | |
model.fit(train_x, train_labels) | |
predicted_labels = model.predict(test_x) | |
print (confusion_matrix(labels[test_indices], predicted_labels)) | |
print (classification_report(labels[test_indices], predicted_labels, digits=4, target_names=namesInLabelOrder)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment