Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Tathagatd96/b81c9411e7e89a874206f7ae99295ac0 to your computer and use it in GitHub Desktop.
Save Tathagatd96/b81c9411e7e89a874206f7ae99295ac0 to your computer and use it in GitHub Desktop.
#Classifier Training
clf=MultinomialNB().fit(X_train_tfidf,twenty_train.target)
docs_new=['God is love','OpenGL on the GPU is fast']
X_new_counts=count_vect.transform(docs_new)
X_new_tfidf=tfidf_transformer.transform(X_new_counts)
predicted=clf.predict(X_new_tfidf)
for doc,category in zip(docs_new,predicted):
print('%r=>%s'%(doc,twenty_train.target_names[category]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment