Views
No views yet
1from transformers import pipeline
2
3classifier = pipeline("text-classification", model="NotThareesh/BBC-News-Classifier-BERT")
4
5labels = {"LABEL_0": "Business", "LABEL_1": "Entertainment", "LABEL_2": "Politics", "LABEL_3": "Sport", "LABEL_4": "Tech"}
6
7text = "The stock market saw a significant rise today after tech companies reported high earnings."
8result = classifier(text)
9
10print(f"Predicted Label: {labels[result[0]['label']]}, Accuracy Score: {result[0]['score']}") # Predicted Label: Business, Accuracy: 0.996