The Wikipedia API might not work all the time depending on the entered search term.
This is a web app which can be used to analyze users' sentiments across Twitter hashtags. 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
-
Download the trained model and put into the
server/main
folder
(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
) -
Run
python -m venv venv
in the terminal from theserver
folder to create a Python virtual environment
(Note: Ensure that you have Python version 3.7 or higher) -
Run
venv/scripts/activate
andpip install -r requirements.txt
while still being inserver
folder to switch to virtual env & install all the required packages -
Start the Flask server by running
python app.py
-
Open
http://localhost:8000
in your browser to access the app
-
Run
npm install
inclient
folder to download all the dependent noad modules -
Make the changes in
client/src
folder as required -
Check the front-end related changes by running
npm start
& openhttp://localhost:5000
in your browser -
Run
npm run build
after all the changes are made to create optimized production build
- Download the Kaggle Sentiment140 dataset and put it in the root folder as
sentiment140.csv
. - Run the code blocks given in the Jupyter Notebook