MINHCT commited on
Commit
22da72a
1 Parent(s): 52f1084

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -9
app.py CHANGED
@@ -13,7 +13,7 @@ vectorizer = joblib.load("vectorizer.joblib") # global vocabulary (used for Logi
13
 
14
  # Decode label function
15
  # {'business': 0, 'entertainment': 1, 'health': 2, 'politics': 3, 'sport': 4}
16
- def categorize(input_number):
17
  print('receive label encoded', input_number)
18
  categories = {
19
  0: 'Business',
@@ -85,15 +85,16 @@ def process_api(text):
85
  SVM_Predicted = SVM_model.predict(processed_text).tolist() # SVC Model
86
  # Seq_Predicted = Seq_model.predict(padded_sequence)
87
  # predicted_label_index = np.argmax(Seq_Predicted)
88
-
89
- test1 = categorize(int(Logistic_Predicted[0]))
90
- test2 = categorize(int(SVM_Predicted[0]))
91
- print('Logistic', int(Logistic_Predicted[0]), test1)
92
- print('SVM', int(SVM_Predicted[0]), test2)
 
93
 
94
  return {
95
- 'Logistic_Predicted':int(Logistic_Predicted[0]),
96
- 'SVM_Predicted': int(SVM_Predicted[0]),
97
  'Article_Content': text
98
  }
99
 
@@ -116,4 +117,7 @@ if url:
116
  result = categorize(url)
117
  article_content = result.get('Article_Content')
118
  st.text_area("Article Content", value=article_content, height=400) # render the article content as textarea element
119
- st.json(result)
 
 
 
 
13
 
14
  # Decode label function
15
  # {'business': 0, 'entertainment': 1, 'health': 2, 'politics': 3, 'sport': 4}
16
+ def decodedLabel(input_number):
17
  print('receive label encoded', input_number)
18
  categories = {
19
  0: 'Business',
 
85
  SVM_Predicted = SVM_model.predict(processed_text).tolist() # SVC Model
86
  # Seq_Predicted = Seq_model.predict(padded_sequence)
87
  # predicted_label_index = np.argmax(Seq_Predicted)
88
+
89
+ # ----------- Debug Logs -----------
90
+ logistic_debug = decodedLabel(int(Logistic_Predicted[0]))
91
+ svc_debug = decodedLabel(int(SVM_Predicted[0]))
92
+ print('Logistic', int(Logistic_Predicted[0]), logistic_debug)
93
+ print('SVM', int(SVM_Predicted[0]), svc_debug)
94
 
95
  return {
96
+ 'Logistic_Predicted':decodedLabel(int(Logistic_Predicted[0])),
97
+ 'SVM_Predicted': decodedLabel(int(SVM_Predicted[0])),
98
  'Article_Content': text
99
  }
100
 
 
117
  result = categorize(url)
118
  article_content = result.get('Article_Content')
119
  st.text_area("Article Content", value=article_content, height=400) # render the article content as textarea element
120
+ st.json({
121
+ "Logistic": result.get("Logistic_Predicted"),
122
+ "SVC": result.get("SVM_Predicted")
123
+ })