Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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
|
92 |
-
y_pred_l1 = (predictions[:, i]
|
93 |
-
y_proba_l1 = probabilities[:, i,
|
94 |
|
95 |
-
# Level 2
|
96 |
-
y_pred_l2 = (predictions[:, i]
|
97 |
-
y_proba_l2 =
|
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']:
|