%reload_ext autoreload
%autoreload 2
%matplotlib inline
import os
os.environ["CUDA_DEVICE_ORDER"]="PCI_BUS_ID";
os.environ["CUDA_VISIBLE_DEVICES"]="0";
from ktrain.text.sentiment import SentimentAnalyzer
classifier = SentimentAnalyzer()
texts = ["The lower pollen count has provided some relief from my allergies.",
"It looks like there will be cost overruns.",
"I will be at a doctor's appointment at 3:30pm.",
"Tesla stock is falling."]
classifier.predict(texts)
[{'POSITIVE': 0.8364812731742859}, {'NEGATIVE': 0.7623286247253418}, {'NEUTRAL': 0.9303346276283264}, {'NEGATIVE': 0.7317317724227905}]
classifier.predict("I got a promotion at work today.", return_all_scores=True)
{'POSITIVE': 0.9378765821456909, 'NEUTRAL': 0.06050467491149902, 'NEGATIVE': 0.0016188238514587283}