How To Perform Sentiment Analysis using NLP and RDA Bots

Movie Reviews usually play a big role in whether audiences who haven’t watched the movie yet would watch it. Movie reviews are a reflection of the movie being interpreted. But it’s too hard to track the value of those interpretations unless there is some analytical method in doing so. In this project, we will be using CloudFabrix’s very own RDA Bots with various functionalities including NLP or Natural Language Processing functions to conduct sentiment analysis which is categorizing opinions analytically by providing them with numbers that reflect a positive, negative or neutral stance of an opinion on a table of IMDB reviews. 

Alright let’s get started

Link to IMDB file: https://www.kaggle.com/datasets/volodymyrgavrysh/imdb-sentiment-10k-reviews-binary-classification

Step 1: Download the link IMBD file

Step 2: Open up AIOps studio and add a new pipeline with the name of your choice

Step 3: Unzip folder and upload IMDB csv file onto AIOps studio editor

Step 4: Type the code / Bolded part is the code /Non-Bolded part is the explanation / ## is comment in the code

## Import File

--> @files:loadfile filename="imdb_10K_sentimnets_reviews 2.csv"

Loads the file into the editor

## Do Sentiment Analysis

--> @nlp:analyze-sentiment description_col = "review"

‘review’ is the name of the column with the IMDB reviews in text. The sentiment analysis bot added the following columns:

  • neg_polarity: Negative polarity
  • neg_subsctivity: Negative Subjectivity
  • neg_sentence: Most negative sentence in the text
  • pos_polarity: Positive polarity
  • pos_subsctivity: Positive Subjectivity
  • pos_sentence: Most Positive sentence in the text

polarity can range from -1 to 1. -1 being very negative, 0 being neutral and 1 being very positive. Subjectivity can be between 0 and 1. 1 being very subjective for an opinion, not necessarily factual. Both polarity and subjectivity are relative numbers.

## Extract Keywords

--> @nlp:extract-keywords description_col = "review"

It adds one more column keyword. These keywords should help prioritize the issue quickly and in an automated manner.

## Replace Null Values

-->  @dm:fixnull columns = "neg_polarity,neg_subjectivity,pos_polarity,pos_subjectivity" & value = 0.0

This bot replaces all null values in the stated columns with the value 0.0.

## Evaluate Sentiment

-->  @dm:eval sentiment = "'Neutral' if not neg_polarity and not pos_polarity else 'Negative' if neg_polarity else 'Positive'"

This bot evaluates the sentiment column and gives “Neutral” as a classification if the review doesn’t have a negative polarity or a positive polarity. if it does have negative polarity then it gives the classification of “Negative” and if it has a positive polarity then it gives the classification of “Positive”. 

## Evaluate Sentiment

-->  @dm:eval sentiment = "'Very Negative' if sentiment == 'Negative' and neg_polarity < -0.5 else sentiment"

This bot evaluates the sentiment column and gives a classification of “Very Negative” if the sentiment is currently “Negative” and negative polarity is smaller than -0.5 and if it’s bigger than -0.5 then it gives the classification of “Negative” only. 

## Evaluate Sentiment

-->  @dm:eval sentiment = "'Very Positive' if sentiment == 'Positive' and pos_polarity > 0.5 else sentiment"

This bot evaluates the sentiment column and gives a classification of “Very Positive” if the sentiment is currently “Positive” and positive polarity is bigger than 0.5 and if it’s smaller than 0.5 then it gives the classification off “Positive” only.

That is how you perform sentiment analysis using CloudFabrix’s very own RDA bots.

Visit RDA Bot Docs to learn more about RDA or contact us if you need more information.

Final Output
Name Of Columns
Vijay Sithambaram
Vijay Sithambaram