MINHCT commited on
Commit
e5faf6c
1 Parent(s): 6bd8770

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -2
app.py CHANGED
@@ -90,6 +90,11 @@ def process_api(text):
90
  # Seq_Predicted = Seq_model.predict(padded_sequence)
91
  # predicted_label_index = np.argmax(Seq_Predicted)
92
 
 
 
 
 
 
93
  # ----------- Debug Logs -----------
94
  logistic_debug = decodedLabel(int(Logistic_Predicted[0]))
95
  svc_debug = decodedLabel(int(SVM_Predicted[0]))
@@ -98,8 +103,14 @@ def process_api(text):
98
  print('SVM', int(SVM_Predicted[0]), svc_debug)
99
 
100
  return {
101
- 'Logistic_Predicted':decodedLabel(int(Logistic_Predicted[0])),
102
- 'SVM_Predicted': decodedLabel(int(SVM_Predicted[0])),
 
 
 
 
 
 
103
  # 'LSTM': decodedLabel(int(predicted_label_index)),
104
  'Article_Content': text
105
  }
 
90
  # Seq_Predicted = Seq_model.predict(padded_sequence)
91
  # predicted_label_index = np.argmax(Seq_Predicted)
92
 
93
+ # ----------- Proba -----------
94
+ Logistic_Predicted_proba = logistic_model.predict_proba(processed_text)
95
+ svm_new_probs = SVM_model.decision_function(processed_text)
96
+ svm_probs = svm_model.predict_proba(svm_new_probs)
97
+
98
  # ----------- Debug Logs -----------
99
  logistic_debug = decodedLabel(int(Logistic_Predicted[0]))
100
  svc_debug = decodedLabel(int(SVM_Predicted[0]))
 
103
  print('SVM', int(SVM_Predicted[0]), svc_debug)
104
 
105
  return {
106
+ 'Logistic_Predicted':{
107
+ 'predicted_label': decodedLabel(int(Logistic_Predicted[0])),
108
+ 'probability': int(float(np.max(Logistic_Predicted_proba))*10000//100)
109
+ },
110
+ 'SVM_Predicted': {
111
+ 'predicted_label': decodedLabel(int(SVM_Predicted[0])),
112
+ 'probability': int(float(np.max(svm_probs))*10000//100)
113
+ },
114
  # 'LSTM': decodedLabel(int(predicted_label_index)),
115
  'Article_Content': text
116
  }