Views
No views yet
1from transformers import pipeline
2
3# Create the pipeline
4emotion_classifier = pipeline('text-classification', model='AdamCodd/distilbert-base-uncased-finetuned-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.9983291029930115}] precision recall f1-score support
sadness 0.9882 0.9485 0.9679 1496
joy 0.9956 0.9057 0.9485 1496
love 0.9256 0.9980 0.9604 1496
anger 0.9628 0.9519 0.9573 1496
fear 0.9348 0.9098 0.9221 1496
surprise 0.9160 0.9987 0.9555 1496
accuracy 0.9521 8976
macro avg 0.9538 0.9521 0.9520 8976
weighted avg 0.9538 0.9521 0.9520 8976
test_acc: 0.9520944952964783
test_loss: 0.121663898229599