A simple sentiment prediction model trained using the sentiment140 dataset.
- Download the
config.pickle,twitter_sentiment_state_dict.ptandsentiment.pyfiles. Make sure the other two files are in the same directory assentiment.py. - Import the
sentiment.pyscript in your program. - Make an object of
SentimentPredictorand 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.