Call Us

Home / Blog / Data Science / Media Analytics

Media Analytics

  • June 26, 2023
  • 3356
  • 91
Author Images

Meet the Author : Mr. Bharani Kumar

Bharani Kumar Depuru is a well known IT personality from Hyderabad. He is the Founder and Director of Innodatatics Pvt Ltd and 360DigiTMG. Bharani Kumar is an IIT and ISB alumni with more than 17 years of experience, he held prominent positions in the IT elites like HSBC, ITC Infotech, Infosys, and Deloitte. He is a prevalent IT consultant specializing in Industrial Revolution 4.0 implementation, Data Analytics practice setup, Artificial Intelligence, Big Data Analytics, Industrial IoT, Business Intelligence and Business Management. Bharani Kumar is also the chief trainer at 360DigiTMG with more than Ten years of experience and has been making the IT transition journey easy for his students. 360DigiTMG is at the forefront of delivering quality education, thereby bridging the gap between academia and industry.

Read More >

Rarely is a digital arena devoid of user comments, whether you consider Twitter or IMDB evaluations. Organisations must tap into these perspectives in the modern world to get insight on their goods and services. Nevertheless, the quantity of this data makes it very hard to measure it manually. Sentiment Analysis from data analytics is used in this situation.

360DigiTMG

What is Sentiment Analysis?

Sentiment Analysis is a use case of Natural Language Processing (NLP) and falls under the category of text classification. Sentiment Analysis analyses and classifies a text into various sentiments, like positive or negative, Happy, Sad or Neutral, etc. Thus, the ultimate aim of sentiment analysis is to decode the underlying mindset, emotion, or in-depth intention of a text. This is also known as Opinion Mining.

Learn the core concepts of Data Science Course video on Youtube:

Gaining Insights and Making Decisions with Sentiment Analysis

As you would have guessed by this point, our use of sentiment analysis is rather standard. But what does it mean and how can businesses hope to gain from it? Let's use an illustration to attempt to explore the same. Imagine you were starting a business that sold tricycles online. When you place a variety of tricycles there, consumers quickly begin to swarm in. After some time, you decide to alter your pricing strategy for tricycles; you now want to lower the cost of the cycles for children under the age of three while concurrently providing discounts on the most in-demand models. We now begin reading through customer feedback for all the different varieties of cycles in order to ascertain which form of tricycles are most in demand. But we'll be confined to one location! We are unable to sit down and go through them all since there are so many. Sentiment analysis can help you escape the trench in this situation.

Sentiment Analysis Use Cases

  • Social Media Monitoring for Brand Management: Branded companies use sentiment analysis to identify their Brand’s public outlook. For instance, a company can pull all Tweets with the company’s tag and do sentiment analysis to learn the company’s public outlook.
  • Product/Service Analysis: manufacturing sectors can perform sentiment analysis on customer reviews to see how well a product or service is reaching out positively or negatively and predict future decisions accordingly.
  • ā¦ Stock Price Prediction: Predicting if there is a chance the stocks of a particular company will rise or fall is very crucial for investors. We can determine the same by performing sentiment analysis on News given in the form of articles containing the organization's name.

Ways to Perform Sentiment Analysis in Python

Python is one of the dominant tools when it is to performing text mining — it offers a wide variety of ways to perform sentiment analysis.

The most popular ones are enlisted here:

  • Using Text Blob
  • Using Vader
  • Using Bag of Words Vectorization-based Models
  • Using LSTM-based Models
  • Using Transformer-based Models

Using text blob:

Python's Text Blob package allows for sentiment analysis and text mining. Sentiment analysis is done using TextBlob quite simply. Polarity and subjectivity are produced as outputs once we supply text as an input. The text input's emotion is shown through polarity. Range is from [-1,1]. Here, a very strong negative feeling is represented by -1, while a very high positive sentiment is represented by 1. Subjectivity determines whether a text input is a fact or a personal opinion. Its range is [0,1], where a number nearer 0 signifies factual knowledge and a value nearer 1 denotes an individual's opinion. Rarely is a digital arena devoid of user comments, whether you consider Twitter or IMDB evaluations. Organisations must tap into these perspectives in the modern world to get insight on their goods and services. Nevertheless, the quantity of this data makes it very hard to measure it manually. Sentiment Analysis from data analytics is used in this situation.

Pip install Textblob

from textblob import TextBlob

text_1 = "The movie was so awesome."

text_2 = "The movie was so terrible."

#Determining the Polarity

p_1 = TextBlob(text_1).sentiment.polarity

p_2 = TextBlob(text_2).sentiment.polarity

#Determining the Subjectivity

s_1 = TextBlob(text_1).sentiment.subjectivity

s_2 = TextBlob(text_2).sentiment.subjectivity

print("Polarity of Text 1 is", p_1)

print("Polarity of Text 2 is", p_2)

print("Subjectivity of Text 1 is", s_1)

print("Subjectivity of Text 2 is", s_2)

360DigiTMG

Using VADER:

VADER (Valence Aware Dictionary and sEntiment Reasoner) is a rule-based sentiment analyzer which is trained on social media text.

Installation:

pip install vaderSentiment

from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer

from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer

sentiment = SentimentIntensityAnalyzer()

text_1 = "The movie was a good balance between cinematography and screenplay."

text_2 = "The burger tastes terrible."

sent_1 = sentiment.polarity_scores(text_1)

sent_2 = sentiment.polarity_scores(text_2)

print("Sentiment of text 1:", sent_1)

print("Sentiment of text 2:", sent_2)

360DigiTMG

Using Bag of Words Vectorization-Based Models

Following are the steps needed to execute sentiment analysis using the Bag of Words Vectorization technique:

Pre-processing training data's text includes normalising, tokenizing, removing stopwords, and stemming/lemmatizing it.

The pre-processed text data may be converted into a bag of words using the Count Vectorization or TF-IDF Vectorization methods.

for accurate prediction, training using an appropriate classification model on the processed data Utilising the Bag of Words Vectorization Approach, a code for sentiment analysis:

We require a labelled dataset in order to create a sentiment analysis model utilising the bag of words vectorization approach. As previously mentioned, Kaggle provided the dataset for this presentation.

We have to use sklearn's count vectorizer to create the BOW., we can use any classifier of our choice, for which an accuracy score of 0.93 is what you can see in the code below:

import pandas as pd

data = pd.read_csv('data.csv')

#Pre-Processing and Bag of Word Vectorization using Countvectorizer

from sklearn.feature_extraction.text import CountVectorizer

from nltk.tokenize import RegexpTokenizer

token = RegexpTokenizer(r'[a-zA-Z0-9]+')

cv = CountVectorizer(stop_words='english',ngram_range = (1,1),tokenizer = token.tokenize)

text_counts = cv.fit_transform(data['sentences'])

#Splitting the data into training and testing

from sklearn.model_selection import train_test_split

X_train, X_test, Y_train, Y_test = train_test_split(text_counts, data['feedback'], test_size=0.25, random_state=5)

#Training the model

from sklearn.naive_bayes import MultinomialNB

MNB = MultinomialNB()

MNB.fit(X_train, Y_train)

#Calculating the accuracy score of the model

from sklearn import metrics

predicted = MNB.predict(X_test)

accuracy_score = metrics.accuracy_score(predicted, Y_test)

print("Accuracy Score: ",accuracy_score)

360DigiTMG

Using transformers based on models:

Transformer-based models are one of the most advanced Natural Language Processing Techniques.

Pip install transformers

Import transformers

360DigiTMG

Conclusion:

Thus, we may draw the conclusion that sentiment analysis can be performed utilising a variety of models, however we were only able to cover a small number of them here, including LSTM, RNN, and BERT models.

Click here to learn Data Science Course, Data Science Course in Hyderabad, Data Science Course in Bangalore

Data Science Placement Success Story

Other Domain Analytics in our 360DigiTMG

Political Analytics, Transit Analytics, Forest Analytics, Wild Analytics, Agriculture Analytics, Army Analytics, E-commerce Analytics, Energy and Resource Analytics, Hospital Analytics, Healthcare Analytics, Hospitality Analytics, Oil and Gas Analytics, Regulatory Analytics, Security Analytics, Trade Analytics, Railway Analytics, Defense Analytics, Education Analytics, Accounting Analytics, Fraud Analytics, Legal and Law Analytics, Banking Analytics, Insurance Analytics, Life Science Analytics, Pharma Analytics, Aviation Analytics, Retail Analytics, Cyber Security Analytics, Supply Chain Analytics, Marketing Analytics

Data Science Training Institutes in Other Locations

Agra, Ahmedabad, Amritsar, Anand, Anantapur, Bangalore, Bhopal, Bhubaneswar, Chengalpattu, Chennai, Cochin, Dehradun, Malaysia, Dombivli, Durgapur, Ernakulam, Erode, Gandhinagar, Ghaziabad, Gorakhpur, Gwalior, Hebbal, Hyderabad, Jabalpur, Jalandhar, Jammu, Jamshedpur, Jodhpur, Khammam, Kolhapur, Kothrud, Ludhiana, Madurai, Meerut, Mohali, Moradabad, Noida, Pimpri, Pondicherry, Pune, Rajkot, Ranchi, Rohtak, Roorkee, Rourkela, Shimla, Shimoga, Siliguri, Srinagar, Thane, Thiruvananthapuram, Tiruchchirappalli, Trichur, Udaipur, Yelahanka, Andhra Pradesh, Anna Nagar, Bhilai, Borivali, Calicut, Chandigarh, Chromepet, Coimbatore, Dilsukhnagar, ECIL, Faridabad, Greater Warangal, Guduvanchery, Guntur, Gurgaon, Guwahati, Hoodi, Indore, Jaipur, Kalaburagi, Kanpur, Kharadi, Kochi, Kolkata, Kompally, Lucknow, Mangalore, Mumbai, Mysore, Nagpur, Nashik, Navi Mumbai, Patna, Porur, Raipur, Salem, Surat, Thoraipakkam, Trichy, Uppal, Vadodara, Varanasi, Vijayawada, Visakhapatnam, Tirunelveli, Aurangabad

Data Analyst Courses in Other Locations

ECIL, Jaipur, Pune, Gurgaon, Salem, Surat, Agra, Ahmedabad, Amritsar, Anand, Anantapur, Andhra Pradesh, Anna Nagar, Aurangabad, Bhilai, Bhopal, Bhubaneswar, Borivali, Calicut, Cochin, Chengalpattu , Dehradun, Dombivli, Durgapur, Ernakulam, Erode, Gandhinagar, Ghaziabad, Gorakhpur, Guduvanchery, Gwalior, Hebbal, Hoodi , Indore, Jabalpur, Jaipur, Jalandhar, Jammu, Jamshedpur, Jodhpur, Kanpur, Khammam, Kochi, Kolhapur, Kolkata, Kothrud, Ludhiana, Madurai, Mangalore, Meerut, Mohali, Moradabad, Pimpri, Pondicherry, Porur, Rajkot, Ranchi, Rohtak, Roorkee, Rourkela, Shimla, Shimoga, Siliguri, Srinagar, Thoraipakkam , Tiruchirappalli, Tirunelveli, Trichur, Trichy, Udaipur, Vijayawada, Vizag, Warangal, Chennai, Coimbatore, Delhi, Dilsukhnagar, Hyderabad, Kalyan, Nagpur, Noida, Thane, Thiruvananthapuram, Uppal, Kompally, Bangalore, Chandigarh, Chromepet, Faridabad, Guntur, Guwahati, Kharadi, Lucknow, Mumbai, Mysore, Nashik, Navi Mumbai, Patna, Pune, Raipur, Vadodara, Varanasi, Yelahanka

Navigate to Address

360DigiTMG - Data Science, Data Scientist Course Training in Bangalore

No 23, 2nd Floor, 9th Main Rd, 22nd Cross Rd, 7th Sector, HSR Layout, Bengaluru, Karnataka 560102

1800-212-654-321

Get Direction: Data Science Course

Make an Enquiry