gabrielchua commited on
Commit
7a3e76a
·
verified ·
1 Parent(s): d7bae94

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -88,13 +88,13 @@ def run_model(model_file: str, embeddings: np.ndarray):
88
  expanded_probabilities = []
89
  expanded_label_names = []
90
  for i, cat in enumerate(label_names):
91
- # Level 1: binary indicator for class 1 only.
92
- y_pred_l1 = (predictions[:, i] == 1).astype(int)
93
- y_proba_l1 = probabilities[:, i, 1] # Probability for class 1
94
 
95
- # Level 2: binary indicator for any positivity (class 1 or 2)
96
- y_pred_l2 = (predictions[:, i] > 0).astype(int)
97
- y_proba_l2 = 1 - probabilities[:, i, 0] # 1 - probability for class 0
98
 
99
  # For certain categories, only the overall (level 2) output is used
100
  if cat in ['binary', 'insults', 'physical_violence']:
 
88
  expanded_probabilities = []
89
  expanded_label_names = []
90
  for i, cat in enumerate(label_names):
91
+ # Level 1 binary
92
+ y_pred_l1 = (predictions[:, i] > 0).astype(int) # y == 1 or y == 2
93
+ y_proba_l1 = 1 - probabilities[:, i, 0] # 1 - P(class 0)
94
 
95
+ # Level 2 binary
96
+ y_pred_l2 = (predictions[:, i] == 2).astype(int) # only y == 2
97
+ y_proba_l2 = probabilities[:, i, 2] # Probability of class 2
98
 
99
  # For certain categories, only the overall (level 2) output is used
100
  if cat in ['binary', 'insults', 'physical_violence']: