How to Perform Sentiment Analysis on Yelp Restaurant Reviews

How to Perform Sentiment Analysis on Yelp Restaurant Reviews

Online reviews have the power to drive customers to or away from your business, and tell you what customers like and dislike about a brand, product, or service.

So, why not turn all that feedback into insights and learn how to improve both the customer experience and your business?

With AI tools, it’s no longer time-consuming to go through all your Yelp reviews, regardless of how many there are.

Instead of spending hours sorting reviews, you can use a sentiment analysis tool to instantly detect emotions in large amounts of text, and combine it with a topic analysis tool for a full and fine-grained analysis of your customer feedback.

Sentiment analysis classifies customer opinions as positive, negative, or neutral, and delivers insights into what customers love or hate about products or services.

Below, we’ll show you how to perform sentiment analysis on a set of Yelp reviews, about a restaurant, using MonkeyLearn’s no-code tools.

How to Perform Sentiment Analysis on a Yelp Dataset

Sentiment analysis uncovers emotions in online reviews, helping you to detect trends and patterns that may not be evident at first glance.

Analyzing the sentiment of a set of Yelp reviews involves a few steps, from collecting your data to visualizing the results.

Fortunately, AI tools like MonkeyLearn make it simple for you to perform sentiment analysis, as they provide ready-to-use models and user-friendly tools to build your own sentiment classifiers.

Ready to get started? Follow these steps to perform sentiment analysis on your Yelp reviews:

  1. Gather Online Yelp Reviews
  2. Clean your Yelp Data
  3. Split Yelp Data into Opinion Units
  4. Create and Train a Yelp Sentiment Analysis Model
  5. Test your Yelp Sentiment Analysis Model
  6. Analyze Online Yelp Reviews
  7. Create a Word Cloud for each Sentiment

1. Gather Yelp Reviews

The first step is to collect your Yelp reviews and export them as a CSV or Excel file. To automate Yelp data collection, use web scraping software:

Visual Web Scraping Tools

Train custom apps to crawl websites and get relevant data without writing any code.

  • Dexi.io: enables you to set up a custom web scraper using a simple UI. Plus, it has an integration with MonkeyLearn to analyze data.
  • ParseHub: a free and easy-to-use web scraper. Just click to select the data you’d like to extract and download the results in Excel or JSON format.
  • Import.io: collect data on a large scale through an intuitive interface. Just point and click on the items you’d like to extract and set up an automation to extract data.

Web Scraping Frameworks

If you are a developer, you can use open-source frameworks to build web scraping tools. Then, you can use these tools to get Yelp data. Some of the most popular web scraping frameworks include Scrapy (for Python), Upton (for Ruby), and Node Crawler (for Javascript).

For this tutorial, we scraped a bunch of restaurant reviews from Yelp.

2. Clean Your Yelp Data

Yelp data is often noisy and contains errors, so you’ll need to pre-process it before performing text analysis.

Cleaning your data makes it easier for machines to process, and you’ll obtain more reliable results.

Usually, preparing data involves tasks like:

  • Removing empty rows and duplicates, or completing missing values.
  • Converting all text data to lowercase.
  • Removing stop words ‒ words, often articles or conjunctions, that appear frequently in texts and don’t add extra information, such as, and, the, which, it, for, at, or if. For sentiment analysis, make sure that you don’t ignore negations. For example, if you remove the word “not” from “The dessert was not good”, you’ll alter the meaning of the sentence and it will be wrongly classified.
  • Removing punctuation marks and special characters.
  • Correcting misspellings and abbreviations.
  • Lemmatization ‒ reducing the inflectional form of words to its root or dictionary form.

Most data analysis tools these days can automate some or all of these pre-processing tasks so that you have ‘prepared data’, ready for machine learning tasks.

3. Split Data into Opinion Units

Online reviews often contain several opinions. Maybe a customer enjoyed the cocktails but found the place crowded. When doing sentiment analysis, it’s key to split text that contains differing opinions, so you can classify them individually.

To separate opinions, use an opinion unit extractor. Try it out, below:

Test with your own text

Results

TagValue
OPINIONThe hotel has a great location
OPINIONbut all in all it was a horrible experience!
OPINIONOnly stayed here because it was the pre-accommodation choice for one of our tours
OPINIONWill never stay here again!

With MonkeyLearn’s tool, you can batch-process your Yelp dataset and receive a new file with all the extracted opinion units.

4. Create and Train a Yelp Sentiment Analysis Model

MonkeyLearn can help you analyze reviews in a simple and intuitive way.

Test this free sentiment analyzer to see how easy it is:

Test with your own text

Results

TagConfidence
Positive99.1%

Pre-trained models are ready-to-use and can quickly analyze data for common use cases. However, you can also choose to build custom models, tailored to your business, for more accurate and relevant results.

Below, we’ll outline the steps to train a model for sentiment analysis on Yelp reviews with MonkeyLearn:

Choose your model.

Request a demo to get started. Log in, go to the dashboard and click on ‘Create model’. Then, select the option to build a Classifier.

MonkeyLearn's creation wizard, with the option to choose a classifier or extractor.

Choose to build a Sentiment Analysis model

You’ll see different classification options. Click on ‘Sentiment Analysis’.

MonkeyLearn's creation wizard showing classification options: topic, sentiment, and intent.

Upload Your Yelp Dataset

You can import your data in a CSV or Excel file, or connect to other data sources like Twitter, Gmail, or Zendek. This is the data that you will use to train your sentiment classifier.

MonkeyLearn's creation wizard showing available sources to upload your text data.

Train your Sentiment Analysis Model

Manually assign sentiment to your texts to train your sentiment analyzer. After tagging a few examples, the model will start making its own predictions. Change the answer if you don’t agree with the result, so the model can keep learning from your criteria.

The more examples you tag, the smarter your model will be.

A user manually tagging email data to train a sentiment analysis model.

5. Test your Sentiment Analysis Model

Go to “Run” and enter some relevant text to see how your classifier works. If you still need to train your model, go back to “Build” and keep tagging more examples.

A user testing the classifier by entering text and clicking on classify text

You can also check the “Stats” section to evaluate your model’s performance.

Accuracy and F1 Score apply to the overall performance of the classifier, while Precision and Recall analyze how it works at a tag level. Also, you’ll see a word cloud showing the most frequent words for each tag. Learn more about classifier statistics.

A view of MonkeyLearn's stats for a sentiment analysis classifier

6. Analyze Online Reviews

Once you’ve finished training your classifier, you can use it to analyze Yelp restaurant reviews. Go to “Run”, choose the option “Batch”, and upload your dataset.

The model will start processing your data. Then, you’ll get an Excel file with all your opinion units classified as Positive, Negative, or Neutral, and a Confidence Score next to each tag. Like this:

Screenshot of a dataset of Yelp reviews classified by sentiment

7. Create a Word Cloud for Each Sentiment

Word clouds help you visualize your data and spot insights at a glance.

You can generate word clouds for each sentiment to discover which words appear more frequently in Yelp reviews about your restaurant. To do this, filter opinions in your processed data by sentiment. Then, copy the text for one sentiment at a time and paste the sentiment bundle into MonkeyLearn’s word cloud generator.

Here’s the word cloud for positive Yelp restaurant reviews:

Word cloud of frequent words appearing on positive restaurant reviews

Let’s see which words appear most often in negative Yelp reviews:

Word cloud of frequent words appearing on negative restaurant reviews

Get Started with Sentiment Analysis on Yelp Reviews

Online reviews, both good and bad, have an impact on your business. Keeping an eye on what customers say about you is crucial to understand what’s working well and what needs improving.

Sentiment analysis helps you take a closer look at your reviews, revealing positive and negative aspects of customers’ experiences. Using AI tools, you can sift through hundreds of opinions in minutes, and get the insights you need to point your business in the right direction.

MonkeyLearn Studio is an all-in-one platform that allows you to perform sentiment analysis and turn results into compelling visualizations. It provides a user-friendly interface and a series of pre-made templates, including one designed for restaurant reviews. Request a free demo and start getting value from your Yelp reviews!

Inés Roldós

October 14th, 2020

Posts you might like...

MonkeyLearn Logo

Text Analysis with Machine Learning

Turn tweets, emails, documents, webpages and more into actionable data. Automate business processes and save hours of manual data processing.

Try MonkeyLearn
Clearbit LogoSegment LogoPubnub LogoProtagonist Logo