Skip to content

Commit

Permalink
print the min and max confusion matrix values
Browse files Browse the repository at this point in the history
  • Loading branch information
AlyaGomaa committed Jan 9, 2024
1 parent 1575b26 commit c700310
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion scripts/threshold_getter.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from pprint import pp
from scripts.extracted_levels import extracted_threat_levels


expirements_number = len(extracted_threat_levels)
metrics = {}
for threshold in range(0, 150):
metrics[threshold] = {}
Expand All @@ -17,6 +17,7 @@
scores: Dict[str, float]

# the dir name aka exp name has the label in it
malicious = True
if 'normal' in exp.lower():
malicious = False

Expand Down Expand Up @@ -53,6 +54,31 @@
metrics[threshold].update({exp: confusion_matrix})


if tn > max_tn or max_tn==0:
max_tn = tn
threshold_with_max_tn = threshold

if tp > max_tp or max_tp==0:
max_tp = tp
threshold_with_max_tp = threshold

if fp < min_fp or min_fp == float('inf'):
min_fp = fp
threshold_with_min_fp = threshold

if fn < min_fn or min_fn == float('inf'):
min_fn = fn
threshold_with_min_fn = threshold

metrics[threshold].update({exp: confusion_matrix})


print(f"Total experiments: {expirements_number}")

print(f"Threshold with min FN: {threshold_with_min_fn}. min FN: {min_fn}")
print(f"Threshold with min FP: {threshold_with_min_fp}. min FP: {min_fp}")
print(f"Threshold with max TP: {threshold_with_max_tp}. max TP: {max_tp}")
print(f"Threshold with max TN: {threshold_with_max_tn} max TN: {max_tn}")



Expand Down

0 comments on commit c700310

Please sign in to comment.