Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Tathagatd96/762893f59fd0eb4a2ec7a4b3890b5cfe to your computer and use it in GitHub Desktop.
Save Tathagatd96/762893f59fd0eb4a2ec7a4b3890b5cfe to your computer and use it in GitHub Desktop.
#SVM Implementation
text_clf=Pipeline([('vect',CountVectorizer()),('tfidf',TfidfTransformer()),('clf',SGDClassifier(loss='hinge',alpha=1e-3,n_iter=5,random_state=42))])
text_clf.fit(twenty_train.data,twenty_train.target)
predicted=text_clf.predict(doc_test)
print "SVM Accuracy:"
print(np.mean(predicted==twenty_test.target))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment