Aspect Based Sentiment Analysis

With a twist of contextual Augmentation with Google BERT and RTT

Manali_Raut
14 min readJan 30, 2021

In this era of “data is the new oil!” the user generated contents plays an important role. Especially text-based, generated mainly via online forums and social media platforms plus contents which carries with it opinions and reviews plays an important role in “Game of Business”. We people, as a customer, are now willing to spend extra money with a corporation that delivers a wonderful service and also we love leaving feedback — good or bad — making them a valuable resource for businesses. So, today we are going to see how the reviews, sentiments can affect the business with the help of Aspect Based Sentiment Analysis.

In this article, I will demonstrate building of Aspect Category Based Model and Polarity Sentiment Model to extract meaningful insights from a large volume of customer reviews. This is an attempt to automate the process of understanding customer’s review and sentiments.
1.Overview
2. Introduction
3. Business use case
4. Mapping to ML problem
5. Understanding the Data
6. Model Architecture
7. Results
8. Conclusion
9. Future Work
10. Acknowledgement
11. References

1. Overview

Aspect-based sentiment analysis in python is fine-grained sentiment analysis, which aims to spot a transparent level of sentiment polarity in relevance a specific aspect to raised granular understanding of the merchandise. This work is concentrated on Aspect based sentiment analysis with contextual augmentation with Google Bert and Round-trip translation (RTT) and the machine learning models XgBoost Algorithm and Neural Network Sequential Model’s accuracies comparison.

Here, first we are going use Google BERT as novel data augmentation for labelled sentences called contextual augmentation. We assumed invariance that sentences are natural whether or not the words within the sentences are replaced with other words with paradigmatic relations. Second is Round-trip translation (RTT), is additionally referred to as re-cursive, back-and-forth, and bi-directional translation. The most assumption of ABSA is that the complete text has all-inclusive polarity.

The dataset we are going use is restaurant review datasets from SemEval 2014. The output we are going to get is that the Ranking of Aspect Categories in range of 1 to 5 and how much percentage the polarity contains by every ranking. Also comparison of the detailed sentiment analysis of the input review on the premise of aspects and polarity mentioned. This is the most efficient way from a business point of view.

WordCloud of Reviews for Aspect based Sentiment Analysis in Python
WordCloud of Customer Reviews for Aspect based Sentiment Analysis in Python

2. Introduction

A customer review is defined as “the feedback of a product or service made by a customer who has purchased and used, or had experience with, the merchandise or service.”

Business provides these product or services, which suggests that communication and relationships with customers are crucial elements of their success. The customer’s feedback or review shared on online or social medium platforms can provide key insights necessary to optimize customer service but still it’s a good challenge for business to parse and organize this huge amount of unstructured data into more digestible and actionable insights. However, machine learning based techniques have potential to extract aspect categories and their corresponding polarities from such user-generated contents. This approach is thought as aspect-based sentiment analysis (ABSA). Aspect-based sentiment analysis goes one step further than sentiment analysis by automatically assigning sentiments to specific features or topics. It involves breaking down text data into smaller fragments, allowing you to get more granular and accurate insights from your data. Consider the subsequent example,

Example of Aspect based Sentiment Analysis in python where Aspect categories is shown.
Img src : https://programmersought.com/article/14933813365/

From only one sentence , two aspect categories and two polarities can be found, giving a real twist to the old sentiment model.

3. Business Use Case

Using reviews to boost products to satisfy customer needs can gives business a strategic advantage and turned reviews into a valuable research tool. Aspect Based Sentiment Analysis with a twist may well be a very versatile text analysis model which can be used across all industries and internal departments to automate business processes, gain powerful and more accurate insights, and make data-driven decisions. Let’s take a look at variety of the ways during which ABSA is getting utilized in business.

3.1 Cloud Kitchen
Cloud kitchen, also called Ghost Kitchen refers to a part where food is prepared and delivered at door steps by taking orders via calls and online ordering platforms. employing a feedback tool to verify that we have corrected a picture of how the given service is being liked by the patrons and what we’ll improve on also helps within the longer run. Also, we cant neglect having a strong loyalty program. It’s of utmost importance once we wish to convert more third-party customers to the specified platform and saving most on commissions.

3.2. Local Search Engine
Local search engine optimization may be a branch of programme optimization (SEO) that focuses on optimizing an internet site to be found in local search results. Local search encompasses all those nifty search terms that scream local, such as:
· Restaurants near me
· doctors near me
· plumbers near me
· Lawyers in [city]
· doctors in [city ]
These businesses achieve the foremost show pride in local SEO thanks to the immediacy of customer reviews and native address information prevalent within the program results pages (SERPs). In keeping with Google, high-quality reviews improve your business’ visibility.

3.3 Product Feedback Analysis
There are huge amounts of feedback available from NPS and other surveys, on social media, online reviews, and much more. Al this textual customer feedback is significant to discovering and solving customer problems. Here’s how aspect-based sentiment analysis are often accustomed be of all this customer feedback.
• Get valuable, granular-level insights from customer feedback.
• Analyzed service and merchandise reviews to induce the successes and failures of your brand, and compare them to your competitor’s.
• Track how customer sentiment changes toward specific features and attributes of a service or product.

4. Mapping to ML problem

The core of this case study is multiclass classification of Aspect Categories and polarity. Every aspect category will have rank in range 1 to 5 with the percentage of polarity for each category. Also will contain Machine Learning models comparison with the obtained accuracies.

4.1.Performance Metrics for ML Algorithms

4.1.1. Accuracy
It is the most common performance metric for classification algorithms. It should be defined as the number of correct predictions made as a ratio of all predictions made. We will easily calculate it by confusion matrix with the assistance of following formula.

Where ,
True Positives (TP) − it’s the case when both actual class & predicted class of knowledge point is 1.
True Negatives (TN) − it’s the case when both actual class & predicted class of knowledge point is 0.
False Positives (FP) − it’s the case when actual class of information point is 0 & predicted class of information point is 1.
False Negatives (FN) − it’s the case when actual class of knowledge point is 1 & predicted class of knowledge point is 0.

4.2. Deployment Tools
Software deployment tools make the strategy of distributing software and updates as easy as possible. Often, these tasks are automatic or scheduled to enable software developers to think about what they’re doing best — writing code.

4.2.1. Python Language
Python may well be a high-level, general-purpose and a extremely popular artificial language. Python artificial language is being employed in web development, Machine Learning applications, along with all innovative technologies in the Software Industry. Python programming language is extremely compatible for Beginners, also for knowledgeable programmers with other programming languages like C++ and Java.

Features in Python
· Easy to code
· Free and Open Source
· Object-Oriented Language
· GUI Programming Support
· High-Level Language
· Extensible feature
· Python is Portable language
· Python is Integrated language

4.2.2.TensorFlow
TensorFlow is an open-source software library. TensorFlow was originally developed by researchers and engineers working on the Google Brain Team within Google’s Machine Intelligence research organization for the requirements of conducting machine learning and deep neural networks research, but the system is general enough to be applicable in an exceedingly wide selection of other domains as well!.tf.contrib.learn is also a high-level TensorFlow library that simplifies the mechanics of machine learning, including the following:
· running training loops
· running evaluation loops
· managing data sets
· managing feeding

4.3 Advantages of Aspect Based Sentiment Analysis

4.3.1. Improve Customer Service
One of the benefits of Aspect based sentiment analysis has the flexibility to trace the key messages from customers’ opinions and thoughts a pair of name. This helps the customer service department in touch in mind of any related issues or problems. because the method allows the organizations to understand their customers better, Aspect based sentiment analysis provides a transparent picture of the problems and persuades the organisation to appear for a solution.

4.3.2. Discovering New Marketing Strategies
With more data and knowledge gathered through Aspect based sentiment analysis, the organizations could develop an efficient marketing strategy. the end result from the strategies is measured from the customers’ positive or negative key messages. By observing the customers’ conversations on their social media and detect the actual key messages related to your brand, specific marketing campaigns could also be designed for the target consumers.

4.3.3. Scalability
Aspect-based sentiment analysis allows businesses to automatically analyze massive amounts of information thoroughly, which saves money, time, and means teams can target more important tasks.

4.4 Constraints

4.4.1. Sarcastic reviews
Sentiment analysis tools can identify and analyse many pieces of text automatically and quickly. But computer programs have problems recognizing things like sarcasm and irony, negations, jokes, and exaggerations — the styles of things a private would have little trouble identifying. And failing to acknowledge these can skew the results. ‘happy’ is additionally classified as a positive word for the requirements of sentiment analysis, but within the phrase “I am not happy at all”, it should be classified as negative. Some Sarcastic reviews:

Img src : Semi-Supervised Recognition of Sarcastic Sentences in Online Product Reviews

4.4.2. Negation Detection
In linguistics, negation may be some way of reversing the polarity of words, phrases, and even sentences. Researchers use different linguistic rules to identify whether negation is occurring, but it’s also important to determine the range of the words that are stuffed with negation words. There are several forms to specific a negative opinion in sentences: Negation is also morphological where it’s either denoted by a prefix (“dis-”, “non-”) or a suffix (“-less”). Negation are implicit, as in “with this act, it’ll be his first and last movie” — it carries a negative sentiment, but no negative words are used.

If you’ve been enjoying this blog and finding it helpful, I have a special request for you. Give me the gift of knowledge and inspiration with buying me a book. Let’s embark on a learning adventure together! 🌟📖

5.Understanding the data

Restaurants Train Data is distributed for Aspect Based Sentiment Analysis (ABSA), Task 4 of SemEval-2014. It consists of 3044 English sentences from the restaurant reviews of Ganu et al. (2009). The initial dataset of Ganu et al. included annotations for coarse aspect categories and overall sentence polarities; then it modified the dataset to include annotations for aspect terms occurring within the sentences, aspect term polarities, and aspect category-specific polarities.

Text: it’s a customer review about the place or product or food etc. Human can have a selected way of writing so sometimes it are often difficult to retrieve what they wants to mention or they feel.

Aspect Term: could be a word or phrase in an exceedingly sentence as we will see within the diagram of introduction.

Aspect category: Aspect category comes from a pre-defined collection, which doesn’t need to appear within the sentence explicitly.

Polarity: Polarity could be a sentiment feel by customer about something . The aim is to spot the sentiment polarity of a specified Aspect term in an exceedingly sentence. It is model as a classification problem.

6. Model Architecture

Formally, Aspect Based Sentiment Analysis is the computational study of people’s opinions, sentiments, evaluations, attitudes, moods, and emotions. Aspect-based sentiment analysis involves two sub-tasks; firstly, detecting the opinion or aspect terms within the given text data, and secondly, finding the sentiment equivalent to the aspect terms detected.

Fig: Architecture of Aspect based Sentiment Analysis

It became very trivial now to hunt out standard training data for text classification and to check model. But without enough training data, the classifiers become worthless. Also, the huge annotated datasets are expensive to be acquired, stored, processed and too time consuming. Then so on boost the classification accuracy, further as make models more robust, the solution is to come back up with new annotated training samples using data augmentation. My goal is to measure the impact of information augmentation methods: Google Bert and RTT. This case study is focused on comparisons of machine learning models across different dataset and measure the performance.

6.1 Exploratory Data Analysis (EDA)
I feel this is the foremost important part of any machine learning project. It refers to the critical process of performing initial investigations on data so on have a far better understanding of the info, discover patterns, to identify anomalies, to check hypothesis and to test assumptions with the assistance of summary statistics and graphical representations.

6.2 Contextual augmentation by Google Bert
BERT stands for Bidirectional Representation for Transformers. it absolutely was proposed by researchers at Google Research in 2018. Although the most aim of that was to boost the understanding of the meaning of queries associated with Google Search. A study shows that Google encountered 15% of latest queries each day. Therefore, it requires the Google computer program to possess a far better understanding of the language so as to grasp the search query.

Img src : https://arxiv.org/pdf/1805.06201

6.3 Data Augmentation by RTT
Round-trip translation (RTT) is additionally referred to as re-cursive, back-and-forth, and bi-directional translation. it’s the method of translating a word, phrase or text into another language (forward translation), then translating the results back to the first language (back translation) .RTT used as augmentation technique to extend the training data.

6.4 XgBoost Classifier
XGBoost is an implementation of Gradient Boosted decision trees. If there’s matter of speed and accuracy, XGBoost is the solution. It’s a strong machine learning algorithm. It can work on regression, classification, ranking, and user-defined prediction problems. The XGBoost model for classification is termed as XGBClassifier. We are able to create and fit it to our training dataset.

6.5 CNN model
Using the Keras Library, we’ll build and train neural networks for both aspect category and sentiment classification. We’ll use a fully-connected network structure with three layers. We first create a Sequential object and use the add function to feature layers to our model. The Dense class is employed to define a fully-connected layer, where each neuron within the network receives input from all the neurons within the previous layer. The input shape is about to 6000, which is that the maximum size of vocabulary created using word embedding, with relu used because the non-linear activation functions. Nonlinear functions transform data such the resulting transformed points can effectively be classified into different classes. The output layer comprises 5 and 4 neurons, one for every class for aspect category and polarity.

7. Result

7.1. Ranking and percentage of Polarity
Sentiment analysis is a source of valuable insights that help to improve your product or service. In the proposed approach, I used XGBoost Algorithm which gives the result of predicted category ranking and percentage of polarities that would be negative, positive, neutral and conflict is as follows:

Following is the CNN result, with the same predicted aspect categories ranking and percentage of polarities.

Both the result predicted that aspect category anecdotes/miscellaneous has the higher ranking than remaining categories. And ambience has the highest positive polarity.

7.2. Accuracy comparison

Following is the aspect category based sentiment model accuracy comparison.

Following is the Polarity Based Sentiment Analysis model accuracy comparison.

Both the models, Aspect category Based Sentiment Analysis and Polarity Based Sentiment Analysis model accuracies comparison shows that the CNN model works well on all three types of data, Resturant data, bert augmented data and RTT augmented data than the xgboost. The CNN accuracies are better than xgboost on the merged set of data also.

8. Conclusion

Aspect-based sentiment analysis with a twist of contextual Augmentation with Google BERT and RTT can help the “Game of Business” to become more customers centric and study the customer’s behaviour by analysing their feedback for product or services. An approach to enhance the performance of model has been achieved with the assistance of contextual augmentation with Google Bert and data augmentation with RTT. Contextual representation is characterized by generating a representation of every word supported the opposite words within the sentence. Therefore, the performance of the classification model is predicted to boost significantly as a results of the rich contextual representations learned from the user-generated content.

9. Future Work

As we can see, there is a growing interest in text sentiment analysis , we can’t be settle on that fact that the given whole review is positive or negative . It’s become concern that what part of review can be positive or negative. I think, in the future, while working on Aspect Based Sentiment Analysis, if there is less focus on accuracy ,that will be okay but there should be a focus on area of determining where you can correlate sentiment with behavior.

10. Acknowledgement

I feel so grateful to Uday Paila and whole AAIC team for their invaluable help. Due to their support, I could finish this case study with better predicted results. Many thanks for people who took time for reading this blog and are also able to share thoughts via comment. I actually appreciate your insights and private connection.

Don’t miss out on the fun — subscribe here and get my articles delivered straight to your inbox!
Sample data links are in references .

You can find the code in python on Github.
You can visit the ML Deployed app
here.
You can visit YouTube also for demo video
here.
You can reach me on
LinkedIn.
Stay tuned!

--

--

Manali_Raut
Manali_Raut

Written by Manali_Raut

Assistant Professor at MIT ADT University, Pune. Exploring Self Learning & Machine Learning World. Wanna explore with me ? Hold a hand & let's deep dive.

Responses (1)

Write a response