Background to Sentiment Analysis
Sentiment analysis is one of the most common NLP problems. The goal is to analyse a text and predict whether the underlying sentiment is positive, negative or neutral.
There are broadly two approaches for sentiment analysis:
Lexicon-Based Methods: These techniques employ dictionaries of words annotated with their semantic polarity and sentiment strength. This is then used to calculate a score for the polarity and/or sentiment of the document. Usually this method gives high precision but low recall. Widely used lexicon-based methods are Vader Sentiment Analyser and TextBlob.
Machine Learning Methods: Such techniques require creating a model by training the classifier with labeled examples. This means that we must first gather a dataset with examples for positive, negative and neutral classes, process this data, and then train the algorithm based on the examples. These methods are used mainly for computing the polarity of the document.
Objective of this Sentiment Analysis Experiment
The primary objective is to build a deep learning (DL) model for sentiment classification, and compare the DL model performance with lexicon-based methods (Vader sentiment analyser and TextBlob). For the purposes of this experiment, the scope will be limited to analysis on Twitter data.
Hypothesis: Our hypothesis is that the DL model should outperform traditional lexicon-based methods in both accuracy and robustness.
Business Use Cases and Applications
There are multiple direct and indirect applications of this experiment. Some of them include:
Social Media monitoring: Analysing sentiments in real-time, allows businesses to gain insights about how customers feel about certain topics, and detect urgent issues in real time before they spiral out of control.
Enhancing customer experience: Sentiment analysis can be used to focus on the customer feedback verbatims where the sentiment is strongly negative. Likewise, businesses can look at positive customer comments to find out why these customers love them.
Competitive research: Competitive analysis involving sentiment analysis can help businesses to understand their weaknesses and strengths and finding ways to stand out.
- Python; for Documentation, Exploratory Data Analysis and Preprocessing using reticulate package and Python regular expressions.
- For Training – AWS Deep Learning AMI (instance type: ps.2xlarge); in order to achieve a fast output considering time of training as a factor, we adopt the use of GPU processors.
- For inference – AWS Deep Learning AMI (instance type: t2.large); Loading the trained model and using it for prediction.
As seen above, the deep learning model developed using fast.ai significantly outperforms the traditional lexical models in sentiment classification. Further, DL enables rapid sentiment analysis as it provides a fast pipeline which does most of the feature engineering behind the scene.
Using pre-trained language models allows us to extend the application of deep learning methods to NLP tasks with limited training data (transfer learning).
Do you have an AI use case you want to explore?
If you’ve got a specific AI use case that you’d like some help exploring, if you’re interested in collaborating with us as partners, or if you’re just interested in finding viable and effective ways to apply AI in your organisation, speak to us today.