Views
No views yet

| precision | recall | f1-score | support | |
|---|---|---|---|---|
| anger | 0.93 | 0.92 | 0.93 | 275 |
| fear | 0.91 | 0.87 | 0.89 | 224 |
| joy | 0.97 | 0.94 | 0.95 | 695 |
| love | 0.80 | 0.91 | 0.85 | 159 |
| sadness | 0.97 | 0.97 | 0.97 | 521 |
| surpirse | 0.73 | 0.89 | 0.80 | 66 |
| accuracy | 0.93 | 2000 | ||
| macro avg | 0.89 | 0.92 | 0.90 | 2000 |
| weighted avg | 0.94 | 0.93 | 0.93 | 2000 |
1from transformers import AutoTokenizer, AutoModelWithLMHead
2
3tokenizer = AutoTokenizer.from_pretrained("mrm8488/t5-base-finetuned-emotion")
4
5model = AutoModelWithLMHead.from_pretrained("mrm8488/t5-base-finetuned-emotion")
6
7def get_emotion(text):
8 input_ids = tokenizer.encode(text + '</s>', return_tensors='pt')
9
10 output = model.generate(input_ids=input_ids,
11 max_length=2)
12
13 dec = [tokenizer.decode(ids) for ids in output]
14 label = dec[0]
15 return label
16
17 get_emotion("i feel as if i havent blogged in ages are at least truly blogged i am doing an update cute") # Output: 'joy'
18
19 get_emotion("i have a feeling i kinda lost my best friend") # Output: 'sadness'Created by Manuel Romero/@mrm8488 | LinkedIn
Made with ♥ in Spain