Example 3 – Movie review sentiment

We're going to use our Naive Bayes classifier to tackle the sentiment analysis problem, or the problem of inspecting a piece of text and determining whether it has an overall positive or negative sentiment. This is a common analysis done in advertising, marketing, and public relations; most brand managers want to know whether people on Twitter have good things or bad things to say about their brand or product.

The training data for this example will come from https://www.imdb.com/. We'll train our classifier on positive and negative movie reviews, and then use our classifier to check untrained (but pre-labeled) reviews to see how many it gets right.

If you haven't done so yet, download the data files from ...

Get Hands-on Machine Learning with JavaScript now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.