Multinomial Naive Bayes

Let's initialize the classifier in a manner identical to our logistic regression classifier, as follows:

from sklearn.naive_bayes import MultinomialNB as MNBmnb_clf = Pipeline([('vect', CountVectorizer()), ('clf',MNB())])

The previous command will measure performance on the following:

mnb_clf.fit(X=X_train, y=y_train)mnb_acc, mnb_predictions = imdb_acc(mnb_clf)mnb_acc # 0.81356

Get Natural Language Processing with Python Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.