SlideShare a Scribd company logo
1 of 19
Twitter topic sentiment
analysis
CREATED BY RAHUL JHA
Background
 This is a simple twitter sentiment analysis project I did during my mid semester break.
It takes a topic and number of inputs to analyse and gives you a nice pictorial
representation of the overall sentiment of that topic.
 On a daily basis, we are constantly bombarded by facts and figures by advertisement
agencies, governments, people etcetera. How will we get to know whether these facts
makes sense or not. I always desired to know what common people think about any
particular topic which is popular right now. I don’t want to just believe on a particular
figure blindly. Then it struck me why not use my newly acquired knowledge of Python
for this purpose. Hence, I got motivated to do this project. Now, I don’t rely on anyone
telling me how common people feel about a particular topic. I can just open up my
script and within few minutes, I can get real time analysis of twitter data about a certain
topic.
Tools Used
 Twitter API
 Twitter is an Excellent source of data about public opinion. It also contains some
sensitive information. Not anyone can get access to this data. As of 20th October 2018,
one need to fill developers form to get the access of this API.
 Python: Specifically, following libraries of the python are used:
 Tweepy: To interact with the Twitter API.
 TextBlob: To do text and sentiment analysis.
 Matplotlib: To plot the results in a Pie char to show the final sentiment.
Python Script
Loading
Libraries and
dependencies
The following libraries need to be loaded before we can actually
query the twitter Application Program Interface (API) and get the
sentiment of the desired input. TextBlob will help us in getting the
sentiment of a particular tweet. The matplotlib is for plotting the
final sentiment. Further, different tweepy sub-modules are loaded
using the python.
Making Connection with Twitter
After loading the required packages,
we need to make a connection to
the twitter API. This requires a
developers account on twitter. With
an account , one will get the keys
and passwords to interact with API.
Python’s Package Tweepy facilitate
this process. I hid the keys and
passwords as they are private
information and can be used
inappropriately.
Getting Twitter Data From the API
The API that we created in the
previous slide can be used to
access many different types of
data. It can be used to access
a particular users data, live
streaming data or data related
to a particular topic which is
the main focus of this project.
Use Of TextBlob to get the Sentiment
The previous script will search for
‘searchTerm’ to get ‘noOfSearch’
tweets. To analyse these tweets, we
can use the TextBlob’s
sentiment.polarity attribute. After
iterating over the tweet object, we
can store the sentiments in various
arrays. To get the pictorial
representation, obtained the
percentage.
Rendering Pie Plot for overall Sentiment
Now, using the rates(positive, negative and neutral) , we can render the pie plot which gives an idea about
overall sentiment about ‘searchTerm’.
We are done with the script. Now, after executing the
script, it will prompt us for two inputs. The first will be
the term that we want to get the sentiment of and the
next will be ‘How many tweets we want to analyse?’.
Now, lets run the scripts for few times and analyse the
sentiment about some common topics.
First
Execution
with
‘metoo’ tag
Metoo with
More
Tweets(1000)
Twitter on (Modi and Rahul)
Twitter on Modi and Rahul(500 tweets)
Twitter on Modi and Rahul(1000 tweets)
Reason For the strange result
In the previous slide, it seems like a lot of people are neutral about Rahul Gandhi
which is actually the case as many people use sarcasm for Rahul Gandhi. The TextBlob
is not good at detecting sarcasm and humour. It can only detect the positive and
negative sentiment using some of the keywords which are a strong indicator of either
of the sentiment. If it does not find any positive or negative phrase in the tweet, it
gives a 0 polarity score which mean no sentiment at all.
Results on Modi is quite alarming for the ruling party as almost 1/3rd of the tweets are
negative. Considering the image of PM, this results is rather alarming.
Lalit Modi: The
result is make sense
as there is negative
emotions against
lalit modi.
Demonetization: Again, there are
large percentage of tweets as
neutral which can also be a sarcasm
or humor against the government’s
move. There were many who were
actually neutral about this move.
Considering the tweet “It is good
move but needs a robust
infrastructure”. This statement is
obviously neutral. The high
percentage indicate that there are
large number of people who aren’t
quite sure about the move.
The main motive behind this was to create a tool which can
work for us and tell us what is the general sentiment of people
on twitter about a certain topic. In twitter, most of the things
work as a particular keyword. Such as #metoo, #narendramodi,
#raga etcetera. Hence, keywords can tell us hidden stories.
I intend to create a more advanced version of this in future such
as getting live sentiment analysis for which advanced machine
capabilities are required.
This finishes the project.

More Related Content

Similar to Twitter sentiment analysis (Project)

Social data analysis using apache flume, hdfs, hive
Social data analysis using apache flume, hdfs, hiveSocial data analysis using apache flume, hdfs, hive
Social data analysis using apache flume, hdfs, hiveijctet
 
Twitter Data Analysis
Twitter Data Analysis Twitter Data Analysis
Twitter Data Analysis Manan Gadhiya
 
IRJET - Implementation of Twitter Sentimental Analysis According to Hash Tag
 IRJET - Implementation of Twitter Sentimental Analysis According to Hash Tag IRJET - Implementation of Twitter Sentimental Analysis According to Hash Tag
IRJET - Implementation of Twitter Sentimental Analysis According to Hash TagIRJET Journal
 
Twitter sentimentanalysis report
Twitter sentimentanalysis reportTwitter sentimentanalysis report
Twitter sentimentanalysis reportSavio Aberneithie
 
Twitter Sentiment Analysis.pdf
Twitter Sentiment Analysis.pdfTwitter Sentiment Analysis.pdf
Twitter Sentiment Analysis.pdfRachanasamal3
 
New sentiment analysis of tweets using python by Ravi kumar
New sentiment analysis of tweets using python by Ravi kumarNew sentiment analysis of tweets using python by Ravi kumar
New sentiment analysis of tweets using python by Ravi kumarRavi Kumar
 
Sentiment analysis of twitter using python
Sentiment analysis of twitter using pythonSentiment analysis of twitter using python
Sentiment analysis of twitter using pythonManan Gadhiya
 
Sentiment Analysis on Twitter data using Machine Learning
Sentiment Analysis on Twitter data using Machine LearningSentiment Analysis on Twitter data using Machine Learning
Sentiment Analysis on Twitter data using Machine LearningIRJET Journal
 
A credibility analysis system for assessing information on twitter
A credibility analysis system for assessing information on twitterA credibility analysis system for assessing information on twitter
A credibility analysis system for assessing information on twitterVenkat Projects
 
Sentiment analysis of Twitter data using python
Sentiment analysis of Twitter data using pythonSentiment analysis of Twitter data using python
Sentiment analysis of Twitter data using pythonHetu Bhavsar
 
Sentiment analysis in twitter using python
Sentiment analysis in twitter using pythonSentiment analysis in twitter using python
Sentiment analysis in twitter using pythonCloudTechnologies
 
social network analysis project twitter sentimental analysis
social network analysis project twitter sentimental analysissocial network analysis project twitter sentimental analysis
social network analysis project twitter sentimental analysisAshish Mundra
 
IRJET- Improved Real-Time Twitter Sentiment Analysis using ML & Word2Vec
IRJET-  	  Improved Real-Time Twitter Sentiment Analysis using ML & Word2VecIRJET-  	  Improved Real-Time Twitter Sentiment Analysis using ML & Word2Vec
IRJET- Improved Real-Time Twitter Sentiment Analysis using ML & Word2VecIRJET Journal
 
American Majority Twitter Manual
American Majority Twitter ManualAmerican Majority Twitter Manual
American Majority Twitter ManualJennifer Raiffie
 
IRJET - Twitter Sentimental Analysis
IRJET -  	  Twitter Sentimental AnalysisIRJET -  	  Twitter Sentimental Analysis
IRJET - Twitter Sentimental AnalysisIRJET Journal
 
Twitter sentiment analysis ppt
Twitter sentiment analysis pptTwitter sentiment analysis ppt
Twitter sentiment analysis pptSonuCreation
 
Sentiment Analysis on Twitter Data Using Apache Flume and Hive
Sentiment Analysis on Twitter Data Using Apache Flume and HiveSentiment Analysis on Twitter Data Using Apache Flume and Hive
Sentiment Analysis on Twitter Data Using Apache Flume and HiveIRJET Journal
 
Sentiment Analysis of Twitter Data
Sentiment Analysis of Twitter DataSentiment Analysis of Twitter Data
Sentiment Analysis of Twitter DataSumit Raj
 
Twitter Sentiment and Network Analysis
Twitter Sentiment and Network AnalysisTwitter Sentiment and Network Analysis
Twitter Sentiment and Network AnalysisXudong Brandon Liang
 
IRJET- Review Analyser with Bot
IRJET- Review Analyser with BotIRJET- Review Analyser with Bot
IRJET- Review Analyser with BotIRJET Journal
 

Similar to Twitter sentiment analysis (Project) (20)

Social data analysis using apache flume, hdfs, hive
Social data analysis using apache flume, hdfs, hiveSocial data analysis using apache flume, hdfs, hive
Social data analysis using apache flume, hdfs, hive
 
Twitter Data Analysis
Twitter Data Analysis Twitter Data Analysis
Twitter Data Analysis
 
IRJET - Implementation of Twitter Sentimental Analysis According to Hash Tag
 IRJET - Implementation of Twitter Sentimental Analysis According to Hash Tag IRJET - Implementation of Twitter Sentimental Analysis According to Hash Tag
IRJET - Implementation of Twitter Sentimental Analysis According to Hash Tag
 
Twitter sentimentanalysis report
Twitter sentimentanalysis reportTwitter sentimentanalysis report
Twitter sentimentanalysis report
 
Twitter Sentiment Analysis.pdf
Twitter Sentiment Analysis.pdfTwitter Sentiment Analysis.pdf
Twitter Sentiment Analysis.pdf
 
New sentiment analysis of tweets using python by Ravi kumar
New sentiment analysis of tweets using python by Ravi kumarNew sentiment analysis of tweets using python by Ravi kumar
New sentiment analysis of tweets using python by Ravi kumar
 
Sentiment analysis of twitter using python
Sentiment analysis of twitter using pythonSentiment analysis of twitter using python
Sentiment analysis of twitter using python
 
Sentiment Analysis on Twitter data using Machine Learning
Sentiment Analysis on Twitter data using Machine LearningSentiment Analysis on Twitter data using Machine Learning
Sentiment Analysis on Twitter data using Machine Learning
 
A credibility analysis system for assessing information on twitter
A credibility analysis system for assessing information on twitterA credibility analysis system for assessing information on twitter
A credibility analysis system for assessing information on twitter
 
Sentiment analysis of Twitter data using python
Sentiment analysis of Twitter data using pythonSentiment analysis of Twitter data using python
Sentiment analysis of Twitter data using python
 
Sentiment analysis in twitter using python
Sentiment analysis in twitter using pythonSentiment analysis in twitter using python
Sentiment analysis in twitter using python
 
social network analysis project twitter sentimental analysis
social network analysis project twitter sentimental analysissocial network analysis project twitter sentimental analysis
social network analysis project twitter sentimental analysis
 
IRJET- Improved Real-Time Twitter Sentiment Analysis using ML & Word2Vec
IRJET-  	  Improved Real-Time Twitter Sentiment Analysis using ML & Word2VecIRJET-  	  Improved Real-Time Twitter Sentiment Analysis using ML & Word2Vec
IRJET- Improved Real-Time Twitter Sentiment Analysis using ML & Word2Vec
 
American Majority Twitter Manual
American Majority Twitter ManualAmerican Majority Twitter Manual
American Majority Twitter Manual
 
IRJET - Twitter Sentimental Analysis
IRJET -  	  Twitter Sentimental AnalysisIRJET -  	  Twitter Sentimental Analysis
IRJET - Twitter Sentimental Analysis
 
Twitter sentiment analysis ppt
Twitter sentiment analysis pptTwitter sentiment analysis ppt
Twitter sentiment analysis ppt
 
Sentiment Analysis on Twitter Data Using Apache Flume and Hive
Sentiment Analysis on Twitter Data Using Apache Flume and HiveSentiment Analysis on Twitter Data Using Apache Flume and Hive
Sentiment Analysis on Twitter Data Using Apache Flume and Hive
 
Sentiment Analysis of Twitter Data
Sentiment Analysis of Twitter DataSentiment Analysis of Twitter Data
Sentiment Analysis of Twitter Data
 
Twitter Sentiment and Network Analysis
Twitter Sentiment and Network AnalysisTwitter Sentiment and Network Analysis
Twitter Sentiment and Network Analysis
 
IRJET- Review Analyser with Bot
IRJET- Review Analyser with BotIRJET- Review Analyser with Bot
IRJET- Review Analyser with Bot
 

Recently uploaded

VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130Suhani Kapoor
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationshipsccctableauusergroup
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionfulawalesam
 
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...Suhani Kapoor
 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% SecurePooja Nehwal
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfLars Albertsson
 
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiVIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiSuhani Kapoor
 
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptxBPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptxMohammedJunaid861692
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxJohnnyPlasten
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfLars Albertsson
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptxAnupama Kate
 
Introduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxIntroduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxfirstjob4
 
Ukraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSUkraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSAishani27
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxStephen266013
 
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Delhi Call girls
 
Unveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data AnalystUnveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data AnalystSamantha Rae Coolbeth
 
Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingNeil Barnes
 

Recently uploaded (20)

VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interaction
 
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdf
 
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiVIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
 
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptxBPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptx
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
 
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in  KishangarhDelhi 99530 vip 56974 Genuine Escort Service Call Girls in  Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx
 
Introduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxIntroduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptx
 
Ukraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSUkraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICS
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docx
 
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
 
Unveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data AnalystUnveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data Analyst
 
Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data Storytelling
 

Twitter sentiment analysis (Project)

  • 2. Background  This is a simple twitter sentiment analysis project I did during my mid semester break. It takes a topic and number of inputs to analyse and gives you a nice pictorial representation of the overall sentiment of that topic.  On a daily basis, we are constantly bombarded by facts and figures by advertisement agencies, governments, people etcetera. How will we get to know whether these facts makes sense or not. I always desired to know what common people think about any particular topic which is popular right now. I don’t want to just believe on a particular figure blindly. Then it struck me why not use my newly acquired knowledge of Python for this purpose. Hence, I got motivated to do this project. Now, I don’t rely on anyone telling me how common people feel about a particular topic. I can just open up my script and within few minutes, I can get real time analysis of twitter data about a certain topic.
  • 3. Tools Used  Twitter API  Twitter is an Excellent source of data about public opinion. It also contains some sensitive information. Not anyone can get access to this data. As of 20th October 2018, one need to fill developers form to get the access of this API.  Python: Specifically, following libraries of the python are used:  Tweepy: To interact with the Twitter API.  TextBlob: To do text and sentiment analysis.  Matplotlib: To plot the results in a Pie char to show the final sentiment.
  • 5. Loading Libraries and dependencies The following libraries need to be loaded before we can actually query the twitter Application Program Interface (API) and get the sentiment of the desired input. TextBlob will help us in getting the sentiment of a particular tweet. The matplotlib is for plotting the final sentiment. Further, different tweepy sub-modules are loaded using the python.
  • 6. Making Connection with Twitter After loading the required packages, we need to make a connection to the twitter API. This requires a developers account on twitter. With an account , one will get the keys and passwords to interact with API. Python’s Package Tweepy facilitate this process. I hid the keys and passwords as they are private information and can be used inappropriately.
  • 7. Getting Twitter Data From the API The API that we created in the previous slide can be used to access many different types of data. It can be used to access a particular users data, live streaming data or data related to a particular topic which is the main focus of this project.
  • 8. Use Of TextBlob to get the Sentiment The previous script will search for ‘searchTerm’ to get ‘noOfSearch’ tweets. To analyse these tweets, we can use the TextBlob’s sentiment.polarity attribute. After iterating over the tweet object, we can store the sentiments in various arrays. To get the pictorial representation, obtained the percentage.
  • 9. Rendering Pie Plot for overall Sentiment Now, using the rates(positive, negative and neutral) , we can render the pie plot which gives an idea about overall sentiment about ‘searchTerm’.
  • 10. We are done with the script. Now, after executing the script, it will prompt us for two inputs. The first will be the term that we want to get the sentiment of and the next will be ‘How many tweets we want to analyse?’. Now, lets run the scripts for few times and analyse the sentiment about some common topics.
  • 13. Twitter on (Modi and Rahul)
  • 14. Twitter on Modi and Rahul(500 tweets)
  • 15. Twitter on Modi and Rahul(1000 tweets)
  • 16. Reason For the strange result In the previous slide, it seems like a lot of people are neutral about Rahul Gandhi which is actually the case as many people use sarcasm for Rahul Gandhi. The TextBlob is not good at detecting sarcasm and humour. It can only detect the positive and negative sentiment using some of the keywords which are a strong indicator of either of the sentiment. If it does not find any positive or negative phrase in the tweet, it gives a 0 polarity score which mean no sentiment at all. Results on Modi is quite alarming for the ruling party as almost 1/3rd of the tweets are negative. Considering the image of PM, this results is rather alarming.
  • 17. Lalit Modi: The result is make sense as there is negative emotions against lalit modi.
  • 18. Demonetization: Again, there are large percentage of tweets as neutral which can also be a sarcasm or humor against the government’s move. There were many who were actually neutral about this move. Considering the tweet “It is good move but needs a robust infrastructure”. This statement is obviously neutral. The high percentage indicate that there are large number of people who aren’t quite sure about the move.
  • 19. The main motive behind this was to create a tool which can work for us and tell us what is the general sentiment of people on twitter about a certain topic. In twitter, most of the things work as a particular keyword. Such as #metoo, #narendramodi, #raga etcetera. Hence, keywords can tell us hidden stories. I intend to create a more advanced version of this in future such as getting live sentiment analysis for which advanced machine capabilities are required. This finishes the project.