Spaces:
Runtime error
Runtime error
Chih-Hsu Lin
commited on
Commit
•
def15ef
1
Parent(s):
419133c
Added uncertainty
Browse files
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"
|
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',
|