Update classification_model_monitor.py
Browse files
classification_model_monitor.py
CHANGED
@@ -160,7 +160,13 @@ def get_misclassified_classes(data):
|
|
160 |
misclassified_examples = data.loc[data['match'] == 0, ['text', 'y_true', 'y_pred', 'y_pred_proba', 'url']].copy()
|
161 |
misclassified_examples.sort_values(by=['y_pred', 'y_pred_proba'], ascending=[True, False], inplace=True)
|
162 |
|
163 |
-
misclassifications = data.loc[data['match'] == 0, 'y_pred'].value_counts()
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
misclassifications /= y_pred_counts
|
165 |
misclassifications.sort_values(ascending=False, inplace=True)
|
166 |
logging.info("Exiting get_misclassified_classes()")
|
|
|
160 |
misclassified_examples = data.loc[data['match'] == 0, ['text', 'y_true', 'y_pred', 'y_pred_proba', 'url']].copy()
|
161 |
misclassified_examples.sort_values(by=['y_pred', 'y_pred_proba'], ascending=[True, False], inplace=True)
|
162 |
|
163 |
+
misclassifications = data.loc[data['match'] == 0, 'y_pred'].value_counts()
|
164 |
+
|
165 |
+
missing_classes = [i for i in y_pred_counts.index if i not in misclassifications.index]
|
166 |
+
for i in missing_classes:
|
167 |
+
misclassifications[i] = 0
|
168 |
+
|
169 |
+
misclassifications = misclassifications[y_pred_counts.index].copy()
|
170 |
misclassifications /= y_pred_counts
|
171 |
misclassifications.sort_values(ascending=False, inplace=True)
|
172 |
logging.info("Exiting get_misclassified_classes()")
|