This web application allows users to analyze sentiments across Twitter hashtags/terms. It's built using React and Django, leveraging an LSTM model trained on the Kaggle Sentiment140 dataset. The model is served as a REST API to the ReactJS frontend.
- Sentiment Analysis: Using an LSTM model to analyze sentiments on Twitter.
- Integration with Tweepy: For fetching real-time tweets.
- Wikipedia API: To provide context about the hashtags.
- Visual Examples: Displaying tweets with their predicted sentiments.
- Additional Resource: A kernel for sentiment classification using CNN + 1D pooling is available here.
- Docker installed on your system.
- Twitter API Bearer Token from Twitter Developer Portal.
-
Model Setup:
- Download the trained CNN model and place it in the
server/main
folder. (Note: To use the LSTM model, follow the training steps below and save the model in theserver/main
folder. Modify the loaded model name inserver/main/init.py
.)
- Download the trained CNN model and place it in the
-
Configuration:
- Add your Twitter API Bearer Token to
server/main/config.py
.
- Add your Twitter API Bearer Token to
-
Starting the App:
- Run
docker-compose up --build
in the terminal from the root directory. - Access the app via https://localhost:3000.
- Run
Run the Kaggle Notebook for CNN Sentiment Classification.
- Download the Kaggle Sentiment140 dataset and place it as
sentiment140.csv
in the root folder. - Execute the code in
Twitter Sentiment Analysis.ipynb
.
(Note: The LSTM model requires more time to train due to its sequential nature. It offers performance similar to the CNN model, but a GPU is recommended for faster processing.)