Complete Guide to Sentiment Analysis: Updated 2020

Complete Guide to Sentiment Analysis: Updated 2020

What is sentiment analysis? If we take your customer feedback as an example, sentiment analysis (a form of text analytics) measures the attitude of the customer towards the aspects of a service or product which they describe in text.

The task of sentiment analysis typically involves taking a piece of text, whether it’s a sentence, a comment or an entire document and returning a “score” that measures how positive or negative the text is.

For example in customer feedback:
Customer feedback text
We’ve also heard sentiment analysis being referred to (less commonly) as opinion mining and emotion AI.

Why sentiment analysis is needed

In today’s environment where we’re justifiably suffering from data overload (although this does not mean better or deeper insights), companies might have mountains of customer feedback collected; but for mere humans, it’s still impossible to analyze it manually without any sort of error or bias.

Oftentimes, companies with the best intentions find themselves in an insights vacuum. You know you need insights to inform your decision making and you know that you’re lacking them, but don’t know how best to get them.

Sentiment analysis provides some answers into what the most important issues are, from the perspective of customers, at least. Because sentiment analysis can be automated, decisions can be made based on a significant amount of data rather than plain intuition that isn’t always right.

Impossible to analyze large amounts of data without error

Imagine this scenario: you’re the owner of a small delivery business and you receive about 20 responses to your email surveys every month. You could (and should), read these yourself and perform your own analysis by hand.

Now, imagine receiving 30,000 responses per month (as many large enterprises do). Whoa, that’s more than a thousand responses that you would need to read and analyze each day.

Needless to say this is impossible as a part of a business owner’s day job (not even the biggest shot of mocha latte will help you there!).

Then, there’s the question of bias.

If you’re having one of “those days” where your alarm doesn’t go off, you rush out the door, spill coffee all over yourself to then be stuck in a traffic jam for 45 minutes, we can be sure that you’re not in the best of moods, coming into the office late.

The risk of you interpreting messages and any form of communication more negatively, is rife.

You might also have your own, preconceived opinions about the topic at hand, and all of this, can influence how you interpret the text you need to analyze.

You’ll also need to summarize the feedback into a few actionable insights, so that it is meaningful for your company to make use of.

Also the insights need to be translated into presentable form so that it is easy to grasp.

Sentiment analysis is important because companies want their brand being perceived positively, or at least more positively than the brands of competitors. Sentiment analysis, if accurate, can be a very valuable tool for this specific use case.

What sentiment analysis is used for

Sentiment analysis is useful for quickly gaining insights using large volumes of text data. In addition to the customer feedback analysis use case, which we touched on above, here are another two examples of where sentiment analysis can be useful.

One example is stock trading companies who trawl the internet for news. Here, sentiment algorithms can detect particular companies who show a positive sentiment in news articles. This can mean a significant financial opportunity, as this may trigger people to buy more of the company’s stock. Having access to this type of data, may give traders the opportunity to make decisions before the market has time to react.

Here is an example of how stock price of a company can be affected by a news event, and as you can imagine, the sentiment expressed in the news of acquisition can be a trigger for a stock trading algorithm to buy the stock before the increase in its price happens.

Sentiment analysis stock price

Another application of sentiment analysis is monitoring and measurement sentiment for social media posts. During the announcement of Brexit, a social media sentiment tool was able to predict that polls around the “remain” camp were incorrect, as much as six hours before the news broke.

Brexit Sentiment Data

Image source: Techcrunch

Sentiment analysis

Source: DMNews

Using sentiment analysis for customer experience

When looking to decrease customer churn, we can use sentiment analysis to focus on the customer feedback verbatims where the sentiment is strongly negative. Likewise, we can look at customer comments which have strongly positive sentiment to find out why these customers love us, and try and focus on what we can do as a business to increase the number of our promoters.

When used in combination with thematic analysis, we can further narrow down this information to find precisely which themes are talked about with positive/negative sentiment, providing actionable insights for your business.

With all of the examples above, we can see sentiment analysis being used by taking a source of text data that has a narrow scope of context and then gauging the polarity of the text.

Two basic techniques for sentiment analysis

1. Rule-based sentiment analysis

The first technique is rules-based and uses a dictionary of words labelled by sentiment to determine the sentiment of a sentence. In order to work well, sentiment scores typically need to be combined with additional rules to mitigate sentences containing negations, sarcasm, or dependent clauses.

Sentiment Dictionary Example:

Word sentiment

-1 = Negative / +1 = Positive

2. Machine Learning (ML) based sentiment analysis

Here, we train an ML model to recognize the sentiment based on the words and their order using a sentiment-labelled training set. This approach depends largely on the type of algorithm and the quality of the training data used.

If we look deeper at the stock trading example mentioned above; we take news headlines, and narrow them to lines which mention the particular company that we are interested in (often done by another NLP technique, called Named Entity Recognition) and then gauge the polarity of the sentiment in the text.

One way to make this approach fit other types of problems is to measure polarity across other dimensions. For example, you could look at specific emotions. How angry was the person when they were writing the text? How much fear is conveyed in the text? In the example of the Brexit model, a measurement is taken for how likely the person writing a tweet was to vote for one side or the other.

Advantages of using sentiment analysis

By using sentiment analysis, you gauge how customers feel about different areas of your business without having to read thousands of customer comments at once.

If you have thousands or even tens of thousands of survey responses per month, it is impossible for one person to read all of these responses and have an unbiased and consistent measure of customer sentiment. By using sentiment analysis and automating this process, you can easily drill down into different customer segments of your business and get a better understanding of sentiment in these segments.

Disadvantages of using sentiment analysis

While sentiment analysis is useful, we do not believe it is a complete replacement for reading survey responses, as there are often useful nuances in the comments themselves. Where sentiment analysis can help you further is by identifying which of these comments you should read, for example allowing you to focus on the most negative comments.

How sentiment analysis actually works

Traditional sentiment analysis involves using reference dictionaries of how positive certain words are and then calculating the average of these scores as the sentiment of that text.

The next step from here is using a simple ML model to make the classification. This is done by generating “features” from the text then using these features to predict a “label”. An example of generating features is splitting the text up into words and then using these words and their frequencies in text as features.

Use ML to assess how positive or negative words are

The “label” will be a measure of how positive or negative the sentiment is. Once the problem has been set up, mathematical optimization techniques are used to create a model. The key difference here is that you are using ML to assign how positive or negative the features or words are, rather than looking this information up in dictionaries.

The traditional ML techniques are able to obtain reasonable results, although suffer from a few problems such as requiring manual work in creating the features, also they do not have a good solution for considering word order. These problems have been addressed by a family of ML techniques known as “Deep Learning”.

Different types of Deep Learning techniques

Deep Learning techniques are also known as Artificial Neural Networks named so because they are loosely analogous to how neurons behave in the brain. These techniques have given great advances in Natural Language Processing in the last few years.

One particular model known as the LSTM (Long Short-Term Memory) has been dominating most NLP tasks in the last few years achieving state of the art results. An LSTM approach reads text sequentially and stores relevant information to the task at hand, for example, plurality, gender, negation and so on.

Within the LSTM there are cells which control what information is remembered and what is forgotten. In the case of sentiment analysis negation is very important, for example, the difference between “great” and “not great”. An LSTM trained to predict sentiment will learn that this is important and get good at understanding which words should be negated. By reading large amounts of text an LSTM can be thought of as ‘learning’ grammar rules.

Deep learning architectures continue to advance with innovations such as the Sentiment Neuron which is an unsupervised system (a system that does not need labelled training data) coming from Also, Google has developed the Transformer and also very recently added pretraining (pre-training is where you train a model on a different task before fine tuning with your specialised dataset) to the transformer with a technique known BERT which is achieving state of the art results across many NLP tasks.

Example of how’s sentiment predicts sentiment based on characters rather than wordsExample of how’s sentiment predicts sentiment based on characters rather than words.

How to use sentiment analysis for customer feedback

Once you have your sentiment scores, what do you do with them? The simplest implementation for customer feedback is to measure the sentiment across each of your responses and take the average as a gauge for your overall sentiment. Track your average sentiment over time to get a feel for how your customers feel towards your business. Building on from here you can look at segmenting the data and comparing different segments, for example, if your business operates in different locations, or perhaps you have some demographic information you can use for segmenting customers.

Further, you can use a text analytics solution, such as Thematic, to further split up the sentiment across different themes found in your data. (And PS. here’s why thematic analysis, if accurate, always beats simple sentiment analysis).

Options for applying sentiment analysis to your business

There are many APIs available and it can be a good thing to try different techniques. The downside with this is that you will need to set it up yourself and provide all of the infrastructures around it. In addition, these sentiment tools are generalised across many different types of text and document data and not specific to customer feedback

Sentiment analysis tools

There are various tools on the market for text analytics and sentiment analysis. Here at Thematic, we’re focused on staying up to date with the latest NLP research and the most successful models used in academia, where there has been a huge amount of progress in the last 4-5 years. Our team at Thematic implements these models and then trains them on a specific dataset for customer feedback. Thereby, we can create a reliable, and accurate analysis for our clients.

Leave a Reply