Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -30,18 +30,16 @@ def predict(title, summary, tokenizer, model):
|
|
30 |
prediction_probs = []
|
31 |
while sum_probs < 0.95:
|
32 |
prediction.append(label_to_theme[classes[ind]])
|
33 |
-
prediction_probs.append(probs[classes[ind]])
|
34 |
sum_probs += probs[classes[ind]]
|
35 |
ind += 1
|
36 |
-
for prob in prediction_probs:
|
37 |
-
prob = str("{:.2f}".format(100 * prob)) + "%"
|
38 |
|
39 |
return prediction, prediction_probs
|
40 |
|
41 |
@st.cache(suppress_st_warning=True)
|
42 |
def get_results(prediction, prediction_probs):
|
43 |
-
frame = pd.DataFrame({'Topic': prediction, 'Confidence': prediction_probs})
|
44 |
-
return frame
|
45 |
|
46 |
label_to_theme = {0: 'Computer science', 1: 'Economics', 2: 'Electrical Engineering and Systems Science', 3: 'Math',
|
47 |
4: 'Quantitative biology', 5: 'Quantitative Finance', 6: 'Statistics', 7: 'Physics'}
|
|
|
30 |
prediction_probs = []
|
31 |
while sum_probs < 0.95:
|
32 |
prediction.append(label_to_theme[classes[ind]])
|
33 |
+
prediction_probs.append(str("{:.2f}".format(100 * probs[classes[ind]])) + "%")
|
34 |
sum_probs += probs[classes[ind]]
|
35 |
ind += 1
|
|
|
|
|
36 |
|
37 |
return prediction, prediction_probs
|
38 |
|
39 |
@st.cache(suppress_st_warning=True)
|
40 |
def get_results(prediction, prediction_probs):
|
41 |
+
frame = pd.DataFrame({'Topic': prediction, 'Confidence': prediction_probs})
|
42 |
+
return frame.to_string(index=False)
|
43 |
|
44 |
label_to_theme = {0: 'Computer science', 1: 'Economics', 2: 'Electrical Engineering and Systems Science', 3: 'Math',
|
45 |
4: 'Quantitative biology', 5: 'Quantitative Finance', 6: 'Statistics', 7: 'Physics'}
|