Views
No views yet
1from transformers import pipeline
2
3# Create the pipeline
4emotion_classifier = pipeline('text-classification', model='AdamCodd/tinybert-emotion-balanced')
5
6# Now you can use the pipeline to classify emotions
7result = emotion_classifier("We are delighted that you will be coming to visit us. It will be so nice to have you here.")
8print(result)
9#[{'label': 'joy', 'score': 0.9895486831665039}] precision recall f1-score support
sadness 0.9733 0.9245 0.9482 1496
joy 0.9651 0.8864 0.9240 1496
love 0.9127 0.9786 0.9445 1496
anger 0.9479 0.9365 0.9422 1496
fear 0.9213 0.9004 0.9108 1496
surprise 0.9016 0.9866 0.9422 1496
accuracy 0.9355 8976
macro avg 0.9370 0.9355 0.9353 8976
weighted avg 0.9370 0.9355 0.9353 8976
test_acc: 0.9354946613311768
test_loss: 0.1809326708316803