The harmonic mean of precision and recall. The standard metric when class imbalance matters.
F1 = 2 × (precision × recall) / (precision + recall)f1_score(tp=8, fp=2, fn=1) → 0.88889
Round to **5 decimal places**.
Similar Problems
Test Cases (2 visible · 2 hidden)
Case 1: Standard case
Input: f1_score(8, 2, 1)
Expected: 0.88889
Case 2: Perfect score
Input: f1_score(10, 0, 0)
Expected: 1.0
⌘↵ Run · ⌘⇧↵ Submit