Skip to content

Instantly share code, notes, and snippets.

@language-engineering
Created October 10, 2012 13:16
Show Gist options
  • Select an option

  • Save language-engineering/3865592 to your computer and use it in GitHub Desktop.

Select an option

Save language-engineering/3865592 to your computer and use it in GitHub Desktop.
from nltk.classify import NaiveBayesClassifier
from nltk.classify.util import accuracy
#Train on a list of reviews
nb_classifier = NaiveBayesClassifier.train(formatted_training_data)
#Test on another list of reviews
print "Accuracy:", accuracy(nb_classifier, formatted_testing_data)
#Print the features that the NB classifier found to be most important in making classifications
nb_classifier.show_most_informative_features()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment