Views
No views yet
1import pandas as pd
2from transformers import pipeline
3import pandas as pd
4import matplotlib.pyplot as plt
5
6
7model_id = 'ithattieu/distilbert-base-uncased-finetuned-emotions-text-classification'
8classifier = pipeline('text-classification', model=model_id)
9
10labels = ['sadness', 'joy', 'love', 'anger', 'fear', 'surprise']
11
12text = 'I am not a really smart lady, which makes it challenging to grasp certain concepts, but you made it super easy to understand NLP and relevant applications. So, thank you!'
13
14preds_df = pd.DataFrame(preds[0])
15preds = classifier(text, return_all_scores=True)
16
17preds_df = pd.DataFrame(preds[0])
18plt.bar(labels, 100 * preds_df["score"], color='C0')
19plt.title(f'"{text}"')
20plt.ylabel("Class probability (%)")
21plt.show()| Training Loss | Epoch | Step | Validation Loss | Accuracy | F1 |
|---|---|---|---|---|---|
| 0.8161 | 1.0 | 250 | 0.3051 | 0.912 | 0.9114 |
| 0.2464 | 2.0 | 500 | 0.2130 | 0.928 | 0.9278 |