Created
April 26, 2017 15:29
-
-
Save vickyqian/548ff5c6e447879c38348807bce96587 to your computer and use it in GitHub Desktop.
Naive Bayes Classifier
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
import nltk | |
training_set = nltk.classify.util.apply_features(extract_features, tweets) | |
# Train the classifier Naive Bayes Classifier | |
NBClassifier = nltk.NaiveBayesClassifier.train(training_set) | |
#ua is a dataframe containing all the united airline tweets | |
ua['sentiment'] = ua['tweets'].apply(lambda tweet: NBClassifier.classify(extract_features(getFeatureVector(processTweet2(tweet))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment