Kalaoke commited on
Commit
4f31466
·
1 Parent(s): dc21a41

add score to output

Browse files
__pycache__/bert_for_sequence_classification.cpython-37.pyc CHANGED
Binary files a/__pycache__/bert_for_sequence_classification.cpython-37.pyc and b/__pycache__/bert_for_sequence_classification.cpython-37.pyc differ
 
__pycache__/bibert_multitask_classification.cpython-37.pyc CHANGED
Binary files a/__pycache__/bibert_multitask_classification.cpython-37.pyc and b/__pycache__/bibert_multitask_classification.cpython-37.pyc differ
 
__pycache__/handler.cpython-37.pyc CHANGED
Binary files a/__pycache__/handler.cpython-37.pyc and b/__pycache__/handler.cpython-37.pyc differ
 
handler.py CHANGED
@@ -32,6 +32,7 @@ tasks = [
32
 
33
 
34
  idtolabel = {"0":"Negative", "1":"Negative", "2": "Neutral", "3":"Positive", "4": "Positive" }
 
35
 
36
  class EndpointHandler():
37
  def __init__(self, path=""):
@@ -72,12 +73,12 @@ class EndpointHandler():
72
 
73
  for idx, x in enumerate(inputs):
74
  label = classifier_pol[idx]['label']
75
- score = classifier_pol[idx]['score']
76
 
77
- if label == '0' and score >= 0.75:
78
- prediction_res.append({"label":"Neutral"})
79
  else:
80
- prediction_res.append({"label":idtolabel.get(classifier_subj[idx]['label'])})
81
  elapsed = 1000 * (perf_counter() - t0)
82
  logger.info("Model prediction time: %d ms.", elapsed)
83
  return prediction_res
 
32
 
33
 
34
  idtolabel = {"0":"Negative", "1":"Negative", "2": "Neutral", "3":"Positive", "4": "Positive" }
35
+ idtoscore = {"0": -1, "1": -1, "2": 0, "3": 1, "4": 1 }
36
 
37
  class EndpointHandler():
38
  def __init__(self, path=""):
 
73
 
74
  for idx, x in enumerate(inputs):
75
  label = classifier_pol[idx]['label']
76
+ prob = classifier_pol[idx]['probability']
77
 
78
+ if label == '0' and prob >= 0.75:
79
+ prediction_res.append({"label":"Neutral", "score":0})
80
  else:
81
+ prediction_res.append({"label":idtolabel.get(classifier_subj[idx]['label']), "score": idtoscore.get(classifier_subj[idx]['label'])})
82
  elapsed = 1000 * (perf_counter() - t0)
83
  logger.info("Model prediction time: %d ms.", elapsed)
84
  return prediction_res