Sentiment Analysis using Deep Learning

Manav Mandal
5 min readApr 22, 2021

--

Hey, guys so I recently made a simple sentiment analysis model using deep learning that can identify positive and negative movie reviews. I also went through a few articles regarding sentiment analysis and realized the importance of this field of study. So here is my experience with sentiment analysis.
So before we go any further let’s get the basics out of the way!

What is Sentiment Analysis?

Wikipedia defines sentiment analysis asSentiment analysis (also known as opinion mining or emotion AI) is the use of natural language processing, text analysis, computational linguistics, and biometrics to systematically identify, extract, quantify, and study affective states and subjective information ‘. To be completely honest I don’t even understand half of it, lets fix that now.

Here is what I understand from my (limited) experience. Sentiment analysis is a technique that is used to determine whether the data is positive, negative, or neutral. Generally, the data that is being evaluated is textual, like movie reviews on IMDB, product reviews on Amazon or Flipkart, comments on a post on a social media platform, etc.

Why do we need Sentiment Analysis?

It is believed that nearly 90% of the world’s data is unstructured and unsorted. This data includes tweets, Instagram posts, Reddit posts, surveys, chats, articles, documents, etc. Now I don’t need to stress how important it is to sort data, now, do I?

Can you imagine going through 10k tweets, chats from customer service? There is just too much data to go through. Sentiment analysis helps to prevent real-time threats to the image and public relations of a business, for example, what if a user wakes up and realizes that he doesn’t like the logo of a company and decides to launch a protest for the same. Now that is what one would call a PR disaster. Sentiment analysis models can help you immediately identify these kinds of situations, so you can take action right away.
People have been expressing their opinions, thoughts, and ideas more freely and openly than ever before, which is extremely good but it comes with its complications. Imagine you create a wonderful app that keeps track of oxygen beds in these times of crisis and this app blows up overnight. People from all over the country are using it and are providing their valuable feedback on Play store. Now it isn’t possible for a single human being to go through 4000+ reviews just to find out whether the app works exactly like it’s meant to or is it facing some difficulties.

This is where sentiment analysis steps in. The algorithm on Play store which allows you to sort the reviews based on positive or critical tags, uses sentiment analysis. Automatically analyzing the reviews such as opinions in a survey, a google form, or social media conversations, allows brands to learn what makes the user happy or frustrated, so that they can tailor products and services to meet the user’s needs.

How is Deep Learning related to Sentiment Analysis?

The task is usually modeled as a classification problem, whereby a classifier is fed a text and returns a category, e.g. positive, negative, or neutral.

Take a look at its implementation:

In the training phase, the model associates a particular text(i.e. the input) to a particular output(i.e. positive, negative, neutral). The feature extractor converts the text into a vector and tags it with emotion to generate the model. In the prediction phase, we try to evaluate the accuracy of the model by using unseen texts(something which the model hasn’t been trained on).
Now there are a lot of ways to go about when it comes to Deep Learning models. I have used LSTM’s in my project so that is what I will be talking about. LSTM’s stand for Long short term memory check out this diagram to get a rough idea about this

So basically what it does is part of the output in the first cell is forwarded to the next one as input. This is very important when it comes to deciding the tone of the voice, but why is this important? Let’s take a look at it.

We need to remember that opinions are subjective. They are subjected to interpretation. For example:

This movie is very interesting

This movie is soo interesting that I fell asleep

In the above reviews ‘interesting’ is the keyword but it means exactly the opposite in the above cases. Until and unless we know what came before and after the keyword, we aren’t able to predict the emotion.

That is exactly the case when it comes to training DL models. LSTM’s provide a way where we get to keep track of the output from the previous cell which can solve the ambiguity problem to some extent.

Sentiment analysis is a tremendously difficult task even for humans. Still, sentiment analysis is worth the effort, even if your sentiment analysis predictions are wrong from time to time.

Go ahead and check out this simple model on GitHub.

Conclusion

Sentiment analysis can be applied to countless aspects of business, from brand monitoring and product analytics to customer service and market research. By incorporating it into their existing systems and analytics, leading brands (not to mention entire cities) can work faster, with more accuracy, toward more useful ends.

Sentiment analysis has moved beyond merely an interesting, high-tech whim, and will soon become an indispensable tool for all companies of the modern age. Ultimately, sentiment analysis enables us to gain new insights and better understand the needs of the customers so that we can do better and more productive work.

That’s it from my side folks!

Thanks for reading! If you enjoyed reading this article, please click the 👏 button and share to help others find it! Feel free to leave a comment 💬 below. You can connect with me on GitHub, LinkedIn

Have some feedback? Let’s be friends on Twitter.

All the best and happy coding!😀

--

--