liveBook · Manning

Naive bayes classifier

As explained in Natural Language Processing in Action, Second Edition

Naive Bayes is a family of probabilistic classifiers based on Bayes' theorem and a conditional-independence assumption among features.

A naive Bayes classifier learns which words predict a target label, using Bayes' theorem and a conditional-independence assumption among features. For sentiment analysis, it replaces hand-written word scores with scores learned from labeled documents. section 2.6.2

A practical text-classification workflow is:

  • Load labeled movie reviews and convert their continuous sentiment ratings into positive or negative labels. section 2.6.2

Movie-review sentiment

The fitted classifier reaches 93.4% agreement with the movie-review labels shown, but applying it to product reviews falls to about 55.7%, illustrating the importance of matching training data to the target domain.

How Natural Language Processing in Action, Second Edition covers it

How deep it goes
Builds a runnable bag-of-words classifier and evaluates predictions, but does not derive Bayes' theorem or classifier internals.
Examples
Demonstrates movie-review and product-review datasets, token-count tables, probability predictions, and sentiment accuracy measurements.
What it assumes
Assumes labeled text data and basic tabular processing while demonstrating tokenization and binary-label construction.
What you can do after
Builds a MultinomialNB sentiment classifier and diagnoses its weaker performance when applied to product reviews.
How it connects
Connects Bayes' theorem and conditional independence with tokenization, bag-of-words representations, sentiment analysis, and dimensionality reduction.

Also explained in

Compare how 5 books explain naive bayes classifier →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Natural Language Processing in Action, Second Edition. The section links point to the parts of the book it draws on.