Created
October 10, 2012 13:16
-
-
Save language-engineering/3865592 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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