Skip to content

agrawal-rohit/tweet-sense

Repository files navigation

App

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.

Features

  • 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.

Untitled Diagram (6)

Getting Started

Prerequisites

Running the Application

  1. 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 the server/main folder. Modify the loaded model name in server/main/init.py.)
  2. Configuration:

    • Add your Twitter API Bearer Token to server/main/config.py.
  3. Starting the App:

    • Run docker-compose up --build in the terminal from the root directory.
    • Access the app via http://localhost:3000.

Training the Model

CNN Model

Run the Kaggle Notebook for CNN Sentiment Classification.

LSTM Model

  • 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.)