Views
No views yet
1from transformers import pipeline
2
3model_path = "citizenlab/twitter-xlm-roberta-base-sentiment-finetunned"
4
5sentiment_classifier = pipeline("text-classification", model=model_path, tokenizer=model_path)
6sentiment_classifier("this is a lovely message")
7> [{'label': 'Positive', 'score': 0.9918450713157654}]
8
9sentiment_classifier("you are an idiot and you and your family should go back to your country")
10> [{'label': 'Negative', 'score': 0.9849833846092224}]
11 precision recall f1-score support
Negative 0.57 0.14 0.23 28
Neutral 0.78 0.94 0.86 132
Positive 0.89 0.80 0.85 51
accuracy 0.80 211
macro avg 0.75 0.63 0.64 211
weighted avg 0.78 0.80 0.77 211