Define the patient-level prediction for each patient as positive or negative
Define the patient-level ground truth for each patient as positive or negative
Count true positives as patients predicted positive and actually positive
Count false positives as patients predicted positive but actually negative
Count false negatives as patients predicted negative but actually positive
Compute precision as TP / (TP + FP)
Compute recall as TP / (TP + FN)
Compute F1 score as 2 × (precision × recall) / (precision + recall)
Use the patient-level TP, FP, and FN counts in the formula
If precision + recall equals 0, set F1 to 0
