tweet-sense
tweet-sense copied to clipboard
Sentiment analysis dashboard for Twitter hashtags
twitter-sentiment-analysis-web-app

This is a web app which can be used to analyze users' sentiments across Twitter hashtags/terms. Its created using React and Django and uses an LSTM model trained on the Kaggle Sentiment140 dataset and served as a REST API to the ReactJS frontend.
The server pulls tweets using tweepy and performs inference using Keras. It also pulls data from the Wikipedia API based the hashtag chosen to display a short description. As part of the analysis, I also added few examples of the tweets and their predicted sentiments. A kernel for another sentiment classification using a CNN + 1D pooling can be found here

How to Use
Running the application
-
Download the trained model and put into the
server/mainfolder
(Note: This is the CNN model. f you want use the LSTM model, you'll need to follow the training steps below and put the saved model inserver/main. Also, don't forget to change the loaded model name inserver/main/init.py) -
Get your Twitter API credentials through Keys and Tokens tab under the Twitter Developer Portal Projects & Apps page and add them to the
/server/main/config.pyfile. -
Run
docker-compose up --buildin the terminal from the root folder
(Note: Ensure that you have Docker installed) -
Open
http://localhost:5000in your browser to access the app
Training the model
(Note: If you have a GPU in your system, I suggest that you train the CNN model. The LSTM model takes longer to train due to its sequential nature, and offer relatively similar performance)
CNN Model
- Copy and run the Kaggle Notebook.
LSTM Model
- Download the Kaggle Sentiment140 dataset and put it in the root folder as
sentiment140.csv. - Run the code blocks given in the
Twitter Sentiment Analysis.ipynb