Commit
·
02249fb
1
Parent(s):
f6e244e
Fix unmatched labels number.
Browse files
app.py
CHANGED
@@ -16,8 +16,12 @@ def plot_bar(value_counts):
|
|
16 |
def plot_confusion_matrix(y_pred, y_true):
|
17 |
cm = confusion_matrix(y_true, y_pred, normalize='true')
|
18 |
fig, ax = plt.subplots(figsize=(6, 6))
|
|
|
|
|
|
|
|
|
19 |
disp = ConfusionMatrixDisplay(confusion_matrix=cm,
|
20 |
-
display_labels=
|
21 |
disp.plot(cmap="Blues", values_format=".2f", ax=ax, colorbar=False)
|
22 |
plt.title("Normalized Confusion Matrix")
|
23 |
return fig
|
|
|
16 |
def plot_confusion_matrix(y_pred, y_true):
|
17 |
cm = confusion_matrix(y_true, y_pred, normalize='true')
|
18 |
fig, ax = plt.subplots(figsize=(6, 6))
|
19 |
+
labels = []
|
20 |
+
for label in SENTI_MAPPING.keys():
|
21 |
+
if (label in y_pred.values) or (label in y_true.values):
|
22 |
+
labels.append(label)
|
23 |
disp = ConfusionMatrixDisplay(confusion_matrix=cm,
|
24 |
+
display_labels=labels)
|
25 |
disp.plot(cmap="Blues", values_format=".2f", ax=ax, colorbar=False)
|
26 |
plt.title("Normalized Confusion Matrix")
|
27 |
return fig
|