Skip to content

Instantly share code, notes, and snippets.

@saiplanner
Forked from vickyqian/naivebayes
Created May 7, 2019 06:19
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 saiplanner/af3a46135d164780cd0761a8fa2cc0e5 to your computer and use it in GitHub Desktop.
Save saiplanner/af3a46135d164780cd0761a8fa2cc0e5 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