A simple sentiment prediction model trained using the sentiment140 dataset.
- Download the
config.pickle
,twitter_sentiment_state_dict.pt
andsentiment.py
files. Make sure the other two files are in the same directory assentiment.py
. - Import the
sentiment.py
script in your program. - Make an object of
SentimentPredictor
and call thepredict()
function on it.
For Example:
predictor = SentimentPredictor()
sentiment = predictor.predict('@AndrewYNg I love you, no homo')
This returns a float in the range (0, 1), 0 being negative sentiment and 1 being positive.