delarosajav95 commited on
Commit
3bc320b
·
verified ·
1 Parent(s): 585c6b4

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +11 -3
README.md CHANGED
@@ -86,14 +86,22 @@ Positive: 0.79%
86
  ```pyhton
87
  from transformers import pipeline
88
 
89
- url = "https://huggingface.co/spaces/delarosajav95/tw-roberta-base-sentiment-FT-v2"
90
 
91
  classifier = pipeline("sentiment-analysis", model=url)
92
 
93
  text = "text to classify"
94
 
95
- result = classifier(text)
96
- print(result)
 
 
 
 
 
 
 
 
97
  ```
98
 
99
  ## Metrics and results:
 
86
  ```pyhton
87
  from transformers import pipeline
88
 
89
+ url = "delarosajav95/tw-roberta-base-sentiment-FT-v2"
90
 
91
  classifier = pipeline("sentiment-analysis", model=url)
92
 
93
  text = "text to classify"
94
 
95
+ result = classifier(text, return_all_scores=True)
96
+
97
+ label_mapping = {"LABEL_0": "Negative", "LABEL_1": "Neutral", "LABEL_2": "Positive"}
98
+ for i, predictions in enumerate(result):
99
+ print("==================================")
100
+ print(f"Text {i + 1}: {text}")
101
+ for pred in predictions:
102
+ label = label_mapping.get(pred['label'], pred['label'])
103
+ score = pred['score']
104
+ print(f"{label}: {score:.2%}")
105
  ```
106
 
107
  ## Metrics and results: