Image source: www.expressanalytics.com
A dataset of sample tweets is taken from the NLTK library and used to create a sentiment analysis model. The model is built using a Naive Bayes Classifier trained on a dataset of positive and negative tweets after preprocessing. The model takes a list of text tokens (that make up a comment) as input and predicts whether the corresponding comment is positive or negative.
First, make sure to install all the requirements:
pip install -r ./requirements.txt
Then, run the train.py script:
python ./train.py --save-to ./models/naive_bayes.mdl --test-size 0.3
The main.py file is a Streamlit app and is deployed to Streamlit Share. Visit the following link to run the app and test it: