Skip to content

Instantly share code, notes, and snippets.

@mateisuica
Created September 11, 2017 18:13
Show Gist options
  • Save mateisuica/3c6b5c6d53a64b1a295c15c86eb99fc4 to your computer and use it in GitHub Desktop.
Save mateisuica/3c6b5c6d53a64b1a295c15c86eb99fc4 to your computer and use it in GitHub Desktop.
Filter and Train Naive Bayes
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.feature_extraction.text import TfidfTransformer
from sklearn.naive_bayes import MultinomialNB
from sklearn.pipeline import Pipeline
text_clf = Pipeline([('vect', CountVectorizer()),
('tfidf', TfidfTransformer()),
('clf', MultinomialNB()),
])
text_clf = text_clf.fit(final_data, target)
print("\nDone training.\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment