It is an automatic process to determining whether a text segment contains objective or opinionated content, and it can furthermore determine the text’s sentiment polarity. The goal of Twitter sentiment classification is to automatically determine whether a tweet’s sentiment polarity is negative or positive.
- You need to have Python 3 installed on your system.
- This bot uses tweepy module.You can install tweepy by using pip. To install tweepy, use this command :
pip install tweepy
git clone https://github.com/tweepy/tweepy.gitcd tweepypython setup.py install
- Next, we need to link our Twitter account to our Python script. Go to Twitter Developer and sign in with your account. Create a Twitter application and generate a Consumer Key, Consumer Secret, Access Token, and Access Token Secret. Now you are ready to begin!Under your import statements store your credentials within variables and then use the second block of code to authenticate your account with tweepy.
CONSUMER_KEY = 'XXXXXX'
CONSUMER_SECRET = 'XXXXXX'
ACCESS_KEY = 'XXXXXX'
ACCESS_SECRET = 'XXXXXX'
auth = tweepy.OAuthHandler(CONSUMER_KEY,CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY,ACCESS_SECRET)
api = tweepy.API(auth)
In order to check if your program is working you could add:
user = api.me()
print (user.name)
This should return the name of your Twitter account in the console.
analysis_neg_pos.py
The analysis of Twitter data is being done in different points of view to mine the opinion or sentiment. Above proposed approach classify the tweets as Positive and Negative tweets which further helps in sentiment analysis and uses that sentiment analysis for further decision making. For this prototype, Twitter API is utilized to gather data in real-time. The prototype back-end tests on retrieving and processing the API data indicate that it is successful in gathering large amounts of data from popular search terms in real-time. However, just relying on individual models did not give a high accuracy consequently pick the top few models to generate a model.