Skip to content

Instantly share code, notes, and snippets.

@vickyqian
Created April 26, 2017 15:29
Show Gist options
  • Save vickyqian/548ff5c6e447879c38348807bce96587 to your computer and use it in GitHub Desktop.
Save vickyqian/548ff5c6e447879c38348807bce96587 to your computer and use it in GitHub Desktop.
Naive Bayes Classifier
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