Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -24,7 +24,7 @@ def beam_prediction_task(data_percentage, task_complexity, theme):
|
|
24 |
raw_cm = compute_average_confusion_matrix(raw_folder)
|
25 |
if raw_cm is not None:
|
26 |
raw_cm_path = os.path.join(raw_folder, "confusion_matrix_raw.png")
|
27 |
-
plot_confusion_matrix_beamPred(raw_cm, classes=np.arange(raw_cm.shape[0]), title=f"Raw Confusion Matrix\n({data_percentage}% data, {task_complexity} beams)", save_path=raw_cm_path, theme)
|
28 |
raw_img = Image.open(raw_cm_path)
|
29 |
else:
|
30 |
raw_img = None
|
@@ -33,7 +33,7 @@ def beam_prediction_task(data_percentage, task_complexity, theme):
|
|
33 |
embeddings_cm = compute_average_confusion_matrix(embeddings_folder)
|
34 |
if embeddings_cm is not None:
|
35 |
embeddings_cm_path = os.path.join(embeddings_folder, "confusion_matrix_embeddings.png")
|
36 |
-
plot_confusion_matrix_beamPred(embeddings_cm, classes=np.arange(embeddings_cm.shape[0]), title=f"Embeddings Confusion Matrix\n({data_percentage}% data, {task_complexity} beams)", save_path=embeddings_cm_path, theme)
|
37 |
embeddings_img = Image.open(embeddings_cm_path)
|
38 |
else:
|
39 |
embeddings_img = None
|
@@ -59,7 +59,7 @@ def compute_f1_score(cm):
|
|
59 |
f1 = np.nan_to_num(f1) # Replace NaN with 0
|
60 |
return np.mean(f1) # Return the mean F1-score across all classes
|
61 |
|
62 |
-
def plot_confusion_matrix_beamPred(cm, classes, title, save_path, theme):
|
63 |
# Compute the average F1-score
|
64 |
avg_f1 = compute_f1_score(cm)
|
65 |
|
|
|
24 |
raw_cm = compute_average_confusion_matrix(raw_folder)
|
25 |
if raw_cm is not None:
|
26 |
raw_cm_path = os.path.join(raw_folder, "confusion_matrix_raw.png")
|
27 |
+
plot_confusion_matrix_beamPred(raw_cm, classes=np.arange(raw_cm.shape[0]), title=f"Raw Confusion Matrix\n({data_percentage}% data, {task_complexity} beams)", save_path=raw_cm_path, theme=theme)
|
28 |
raw_img = Image.open(raw_cm_path)
|
29 |
else:
|
30 |
raw_img = None
|
|
|
33 |
embeddings_cm = compute_average_confusion_matrix(embeddings_folder)
|
34 |
if embeddings_cm is not None:
|
35 |
embeddings_cm_path = os.path.join(embeddings_folder, "confusion_matrix_embeddings.png")
|
36 |
+
plot_confusion_matrix_beamPred(embeddings_cm, classes=np.arange(embeddings_cm.shape[0]), title=f"Embeddings Confusion Matrix\n({data_percentage}% data, {task_complexity} beams)", save_path=embeddings_cm_path, theme=theme)
|
37 |
embeddings_img = Image.open(embeddings_cm_path)
|
38 |
else:
|
39 |
embeddings_img = None
|
|
|
59 |
f1 = np.nan_to_num(f1) # Replace NaN with 0
|
60 |
return np.mean(f1) # Return the mean F1-score across all classes
|
61 |
|
62 |
+
def plot_confusion_matrix_beamPred(cm, classes, title, save_path, theme=None):
|
63 |
# Compute the average F1-score
|
64 |
avg_f1 = compute_f1_score(cm)
|
65 |
|