There's more...

We can see that we almost achieve 60% accuracy on predicting the sentiment. For example, it is a hard task to know the meaning behind the word great; it could be used in a negative or positive context within a review.

To tackle this problem, we want to somehow create embeddings for the documents themselves and address the sentiment issue. Usually, a whole review is positive or a whole review is negative. We can use this to our advantage, and we will look at how to do this in the Using doc2vec for sentiment analysis recipe that follows.

Get TensorFlow Machine Learning Cookbook - Second Edition 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.