Sentiment Analysis Of Yelp User Review Data

Posted on Aug 22, 2016

Social data provides important, real-time insights on consumer opinion – on lifestyle, habits, brands, and preferences. Because these opinions are unsolicited, they provide genuine insight into consumer feelings, and, as such, they should be valued. Yelp provides restaurant details including name, price, rating, address and reviews. The ratings given by the users say how good the restaurant is, but do you really think that the ratings alone is sufficient to give the correct information? No, because people who really hated a restaurant would comment on their experience.  The same goes for a the good experience. So, Thus, one would expect that performing sentiment analysis would give give a better insight about judging a into the masses’ opinions of restaurants.

Web Scraping:

Web Scraping the to scrape the restaurant data. The data I scraped Restaurant data was scraped from Yelp using the python package BeautifulSoup. The data consists of information such as restaurant name, rating, price, number of reviews, address and user reviews.  I split the web scraping module into two tasks. The first one is to scraped the  restaurant name, rating, price, number of reviews and address. The second one is to scraped the restaurant name and user reviews. The data sets were then merged. Finally, we merge the two datasets. We use BeautifulSoup to scrape the data.

Module 1:

The code used to scrape the first model is as follows

Module 2:

The code used to scrape the second model is as follows

Exploratory Data Analysis:

My scraping was restricted to the restaurants in a 2 mile radius around Times Square. I scraped the restaurants in and around Times Square. To be precise, I scraped the restaurants placed in a 2 mile radius.


The distribution of the ratings is as follows


Most of the restaurants in the first 20 pages of the yelp data has have a rating of 4.

The distribution of the number of reviews is as follows


The distribution shows that the majority of the restaurant reviews range from 0 to 1000.


Sentiment Analysis:

Sentiment Analysis was performed using the Natural Language Toolkit. The name of the specific package used is called Vader Sentiment. VADER (Valence Aware Dictionary and sEntiment Reasoner) is a lexicon and rule-based sentiment analysis tool that is specifically attuned to sentiments expressed in social media, and works well on texts from other domains. The code for Sentiment analysis is as follows:

It works on the word level, by classifying splitting each word into either positive, negative, or neutral. I want to We concentrate on the positive and negative words as neutral words doesn't add value. The plot of the sentiment analysis is as follows


There are few interesting observations showing that  reviews and ratings contradict. The plot of those observations are as follows



A restaurant with a rating of 4 has an equal mixture of negative and positive  words. It’s safe to say that these reviews are mixed So the restaurant has mixed reviews.




The restaurant has a rating of 4, but the sentiment analysis says that the restaraunt has more negative reviews than positive reviews.


Future Scope:

The algorithm can be combined with the the text mining so that the dish name specified in the reviews can be combined with incorporated into the sentiment analysis algorithm to give an output saying that say whether or not a particular dish is associated with has a positive sentiment or negative sentiment and a overall score can be specified.

About Author

Leave a Comment

Your email address will not be published. Required fields are marked *

faux bulgari bijoux January 6, 2018
Awesome speech. Loved his saying that our soldiers deserve to return home to a united country not at war with itself. What a terrific take on these absurd times we’re in. And loved his taking it to the Pakistanis … the gravy train is over, kids. And … LOVED that I don’t have to hear Obama’s infuriating PC pronunciation of PAHH-kee-STAAHN. Gimme a break. faux bulgari bijoux
Carroll December 9, 2017
I was curious if you ever considered changing thee structure of your site? Its very well written; I love what youve gott to say. But maybe you could a little more in the way of content so people could connect with it better. Youve got an awful lot of text for only having 1 or two images. Maybe you could space it out better?
bonussite September 29, 2017
Good article. I certainly love this website. Keep writing!
Modesto Salsberry May 25, 2017
Some truly nice and useful information on this internet site, likewise I believe the pattern has superb features.
hot girls and boys 3d art vol 2 the last part November 19, 2016
If you desire to increase your knowledge only keep visiting this web site and be updated with the hottest news posted here.
talk to crossdressers November 17, 2016
The impressive horror role of Tim Curry as Pennywise evil. Victoria Beckham who rose to fame with the late 1990s girl pop group the Spice Girls has found success as an globally recognized and photographed style icon. But it is worth noting that one of the monster trucks is a prototype, and very hard to get hold of.

View Posts by Categories

Our Recent Popular Posts

View Posts by Tags