This is a simple program to conduct sentiment analysis on any given user input. This is my first Machine Learning model.
- Python 3
- NLTK (Natural Language Toolkit)
- Scikit-Learn (Sklearn)
Visit: https://www.python.org/downloads/ and download the version suitable for your System
Open Command Prompt (Windows) or Terminal (Linux) and type in the following command:
pip install nltk
Open Python in Command Prompt and type
import nltk
nltk.download()
The following window will appear:
Select "all" and click on "Download"
Visit: NLTK Install Instructions for details.
Open Command Prompt (Windows) or Terminal (Linux) and type in the following command:
pip install sklearn
Visit: Scikit-learn Installation Documentation for details.
- Download the dataset from HERE (Both
positive.txt
andnegative.txt
) - Put them in the desired path and change the path of the
train.py
andtest.py
accordingly. - Train the model (using
train.py
) and save the classifier by pickling it at the desired location. - You can directly run the classifier after training or load the saved classifier and run it later using the
test.py
- Input a word and press enter, the model would predict if the word is a positive one or negative.
- You can also input a sentence, however, it does not perform very accurately since it is a simple word based model