- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Twitter Sentiment Analysis using Python Program
In this article, we will be learning about the twitter sentimental analysis. We will register for twitter oAuth API, install all the dependencies and finally write our sentimental analyzer script.
An API(Application programming interface) is a gateway that allows you to access some servers(Twitter) internal functionality.
The prerequisite is that we have a twitter account set up with verified phone number.
After this, we visit the twitters website and tap on the create a new app icon. Now we fill all the credentials i.e. name and accept the developer agreement and finally click on create.
Now our app is created , on the top menu, we will click on the keys tab . Here we will be obtaining our oAuth verfication details and all the tokenizers.
Now let's install all the dependencies −
1. tweepy module
>>> pip install tweepy
2. textblob module
>>> pip install textblob
what is textblob ?
It is a module used in sentiment analysis. It contains an inbuilt method to calculate sentiments on a scale of -1 to 1 .
First we need all the access tokenizer from the twitter application website as created initially −
#Twitter credentials for the app interface consumer_key = 'xxxxx' consumer_secret = 'xxxx' access_key= 'xxxx' access_secret = 'xxxx'
No we need to authenticate the credentials via script. For that, we create an authentication variable auth.
auth = tweepy.OauthHandler(consumer_key,consumer_secret)
now we set the access token with the help of authentication variable
Now we create an API variable to perform our operations
api = tweepy.API(auth)
we need to get the public tweets via search method and store it in the form of a list.
public_tweet = api.search('Tutorialspoint') for tweet in public_tweet: print(tweet.text) analysis = TextBlob(tweet.text) print(analysis)
In the output, we observe to thing i.e. the polarity and subjectivity.
Polarity measures how positive or negative some text is.
Subjectivity measures the text that how much it is opinionated as compared to factual.
By the help of this sentiment analyzer, we are able to understand and extract human feelings out of the data.
- Twitter Sentiment Analysis using Python
- Twitter Sentiment Analysis using Python Programming.
- Data analysis using Python Pandas
- Data analysis and Visualization with Python program
- Exploratory Data Analysis in Python
- Python Data analysis and Visualization
- Analysis of Different Methods to find Prime Number in Python program
- Trend Analysis Vs Ratio Analysis
- How to increase twitter followers?
- Data Analysis and Visualization in Python?
- Compare trend analysis and comparative analysis.
- Best ways to improve twitter conversation
- Asymptotic Analysis
- Amortized Analysis
- PESTEL Analysis