seal345 commited on
Commit
f022026
1 Parent(s): 9b74993

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -24
app.py CHANGED
@@ -29,10 +29,10 @@ def get_predictions(logits, indexes):
29
  return ind, probs
30
 
31
 
32
- def return_pred_name(name_dict, ind):
33
  out = []
34
  for i in ind:
35
- out.append(name_dict[i])
36
  return out
37
 
38
 
@@ -49,7 +49,7 @@ def predict(title, summary, model, tokenizer):
49
  prediction = []
50
  prediction_probs = []
51
  while sum_probs < 0.95:
52
- prediction.append(name_dict[classes[ind]])
53
  prediction_probs.append(str("{:.2f}".format(100 * probs[classes[ind]])) + "%")
54
  sum_probs += probs[classes[ind]]
55
  ind += 1
@@ -61,28 +61,27 @@ def get_results(prediction, prediction_probs):
61
  frame = pd.DataFrame({'Category': prediction, 'Confidence': prediction_probs})
62
  frame.index = np.arange(1, len(frame) + 1)
63
  return frame
 
64
 
65
- name_dict = {4: 'cs',
66
- 19: 'stat',
67
- 1: 'astro-ph',
68
- 16: 'q-bio',
69
- 6: 'eess',
70
- 3: 'cond-mat',
71
- 12: 'math',
72
- 15: 'physics',
73
- 18: 'quant-ph',
74
- 17: 'q-fin',
75
- 7: 'gr-qc',
76
- 13: 'nlin',
77
- 2: 'cmp-lg',
78
- 5: 'econ',
79
- 8: 'hep-ex',
80
- 11: 'hep-th',
81
- 14: 'nucl-th',
82
- 10: 'hep-ph',
83
- 9: 'hep-lat',
84
- 0: 'adap-org'}
85
-
86
 
87
 
88
  st.title("Find out the topic of the article without reading!")
 
29
  return ind, probs
30
 
31
 
32
+ def return_pred_name(names, ind):
33
  out = []
34
  for i in ind:
35
+ out.append(names[i])
36
  return out
37
 
38
 
 
49
  prediction = []
50
  prediction_probs = []
51
  while sum_probs < 0.95:
52
+ prediction.append(names[classes[ind]])
53
  prediction_probs.append(str("{:.2f}".format(100 * probs[classes[ind]])) + "%")
54
  sum_probs += probs[classes[ind]]
55
  ind += 1
 
61
  frame = pd.DataFrame({'Category': prediction, 'Confidence': prediction_probs})
62
  frame.index = np.arange(1, len(frame) + 1)
63
  return frame
64
+
65
 
66
+ names = {3: 'cs',
67
+ 18: 'stat',
68
+ 10: 'math',
69
+ 14: 'physics',
70
+ 15: 'q-bio',
71
+ 0: 'astro-ph',
72
+ 2: 'cond-mat',
73
+ 17: 'quant-ph',
74
+ 5: 'eess',
75
+ 1: 'cmp-lg',
76
+ 8: 'hep-ph',
77
+ 6: 'gr-qc',
78
+ 9: 'hep-th',
79
+ 12: 'nlin',
80
+ 4: 'econ'
81
+ 16: 'q-fin',
82
+ 7: 'hep-ex',
83
+ 11: 'math-ph',
84
+ 13: 'nucl-th'}
 
 
85
 
86
 
87
  st.title("Find out the topic of the article without reading!")