Chih-Hsu Lin commited on
Commit
def15ef
1 Parent(s): 419133c

Added uncertainty

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -23,14 +23,14 @@ def pred_is_elon_musk(text):
23
  logis = results['logits'].detach()
24
  prob = F.softmax(logis, dim=1)[0][1]
25
  prediction = np.argmax(logis.numpy(), axis=1).flatten()
26
- output1 = f"It's from Elon Musk with {prob*100: 0.2f}% probability."
27
  if 0.4 <= prob <= 0.6:
28
  output2 = f"Therefore, maybe it's from Elon Musk or maybe not."
29
  elif prediction[0] == 1:
30
  output2 = f"Therefore, maybe it is from Elon Musk."
31
  else:
32
  output2 = f"Therefore, maybe it is Not from Elon Musk."
33
- return output1+output2
34
 
35
  iface = gr.Interface(pred_is_elon_musk, inputs="text",
36
  outputs="text", title='“Is the tweet from Elon Musk?” Classifier',
 
23
  logis = results['logits'].detach()
24
  prob = F.softmax(logis, dim=1)[0][1]
25
  prediction = np.argmax(logis.numpy(), axis=1).flatten()
26
+ output1 = f"The predicted probability is {prob*100: 0.2f}%.\n"
27
  if 0.4 <= prob <= 0.6:
28
  output2 = f"Therefore, maybe it's from Elon Musk or maybe not."
29
  elif prediction[0] == 1:
30
  output2 = f"Therefore, maybe it is from Elon Musk."
31
  else:
32
  output2 = f"Therefore, maybe it is Not from Elon Musk."
33
+ return output1 + output2
34
 
35
  iface = gr.Interface(pred_is_elon_musk, inputs="text",
36
  outputs="text", title='“Is the tweet from Elon Musk?” Classifier',