Skip to content

Instantly share code, notes, and snippets.

@lievcin
Created February 12, 2018 11:17
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 lievcin/2c9c59804595152ca5d83322410041b0 to your computer and use it in GitHub Desktop.
Save lievcin/2c9c59804595152ca5d83322410041b0 to your computer and use it in GitHub Desktop.
from sklearn import metrics
from sklearn.naive_bayes import MultinomialNB
nb_classifier = MultinomialNB()
nb_classifier.fit(count_train, y_train)
pred = nb_classifier.predict(count_test)
score = metrics.accuracy_score(y_test, pred)
print('Classifier accuracy: ' + str(round(100*score, 2)) + '%')
cm = metrics.confusion_matrix(y_test, pred, labels=['negative', 'mweh', 'positive'])
print('Confusion matrix:')
print(cm)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment