Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Python Artificial Intelligence Projects for Beginners

You're reading from  Python Artificial Intelligence Projects for Beginners

Product type Book
Published in Jul 2018
Publisher Packt
ISBN-13 9781789539462
Pages 162 pages
Edition 1st Edition
Languages
Author (1):
Dr. Joshua Eckroth Dr. Joshua Eckroth
Profile icon Dr. Joshua Eckroth
Toc

Detecting positive or negative sentiments in user reviews


In this section, we're going to look at detecting positive and negative sentiments in user reviews. In other words, we are going to detect whether the user is typing a positive comment or a negative comment about the product or service. We're going to use Word2Vec and Doc2Vec specifically and the gensim Python library for those services. There are two categories, which are positive and negative, and we have over 3,000 different reviews to look at. These come from Yelp, IMDb, and Amazon. Let's begin the code by importing the gensim library, which provides Word2Vec and Doc2Vec for logging to note status of the messages:

First, we will see how to load a pre-built Word2Vec model, provided by Google, that has been trained on billions of pages of text and has ultimately produced 300-dimensional vectors for all the different words. Once the model is loaded, we will look at the vector for cat. This shows that the model is a 300-dimensional...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}