F-score Calculators

0 calculators tagged with “F-score

The F-score (F-measure) is a metric for evaluating the performance of binary classifiers that balances precision (the fraction of positive predictions that are correct) and recall (the fraction of actual positives that are detected). F1-score = 2 × (precision × recall) / (precision + recall) — the harmonic mean of precision and recall. The F-score is particularly valuable for imbalanced datasets where accuracy is misleading (a model predicting all negatives achieves high accuracy if positives are rare). The Fβ-score generalizes the F1 by weighting recall β times as important as precision.

All Calculators

No calculators found for this topic.

Precision, Recall, and F1

From a confusion matrix: TP = true positives; FP = false positives; FN = false negatives; TN = true negatives. Precision = TP / (TP + FP) — of all positive predictions, what fraction are correct? Recall (Sensitivity) = TP / (TP + FN) — of all actual positives, what fraction are detected? F1 = 2 × P × R / (P + R) = 2TP / (2TP + FP + FN)

Fβ Score

Fβ = (1 + β²) × P × R / (β² × P + R)

β = 1: equal weight (F1). β = 2 (F2): weights recall twice as much as precision (use when missing positives is more costly — medical diagnosis). β = 0.5 (F0.5): weights precision twice as much as recall (use when false positives are more costly — spam filtering).

When to Use F-Score

Imbalanced classes: if 99% of examples are negative, a model predicting all negatives has 99% accuracy but F1 = 0. F1 better reflects real performance. Medical diagnosis: often care more about recall (sensitivity) than precision → use F2. Information retrieval: precision and recall both matter → F1 standard.

Glossary

F1-Score
F1 = 2×P×R/(P+R); harmonic mean of precision and recall; ranges 0–1; preferred over accuracy for imbalanced datasets; F1 = 0 if either precision or recall = 0.
Precision
TP/(TP+FP); fraction of positive predictions that are correct; high precision = few false alarms; traded off against recall; prioritized when false positives are costly.
Fβ-Score
(1+β²)×P×R/(β²P+R); β=1 (F1, equal weight); β=2 (F2, recall weighted more — use for medical diagnosis); β=0.5 (F0.5, precision weighted more — use for spam filtering).

Frequently Asked Questions

The F1-score is the harmonic mean of precision and recall: F1 = 2 × (P × R)/(P + R). It evaluates how well a binary classifier performs, especially when the cost of false positives and false negatives differs. Precision: how many of the predicted positives are actually positive (low FP rate). Recall (Sensitivity): how many of the actual positives are detected (low FN rate). Harmonic mean: the harmonic mean is lower than the arithmetic mean and is dominated by whichever of P or R is smaller — so F1 is only high when BOTH precision and recall are high. F1 = 0 if either P = 0 or R = 0. F1 = 1 only if P = R = 1 (perfect).

Accuracy = (TP + TN) / (TP + FP + TN + FN). For heavily imbalanced datasets (e.g., 99% negative, 1% positive — cancer screening where most patients don't have cancer): A model that always predicts 'negative' achieves 99% accuracy but has 0% recall and F1 = 0. It detects no cancer cases at all — useless clinically. F1-score: the model with 0% recall gets F1 = 0; correctly penalized. Better metrics for imbalanced problems: F1 or Fβ (choose β based on relative cost of FP vs. FN); ROC-AUC (area under the receiver operating characteristic curve); PR-AUC (area under precision-recall curve); Matthews correlation coefficient (MCC).

Confusion matrix for binary classifier (positive = disease present; negative = disease absent): True Positive (TP): predicted positive, actually positive. False Positive (FP): predicted positive, actually negative (Type I error). False Negative (FN): predicted negative, actually positive (Type II error). True Negative (TN): predicted negative, actually negative. Example: TP=80; FP=20; FN=30; TN=870. Precision = 80/(80+20) = 0.80. Recall = 80/(80+30) = 0.727. F1 = 2×0.80×0.727/(0.80+0.727) = 1.163/1.527 = 0.762. Accuracy = (80+870)/1000 = 0.950 — much higher than F1, reflecting high TN rate.

Fβ = (1+β²) × P × R / (β²P + R). β > 1: recall is weighted β times more than precision → use when missing a positive (FN) is more costly than falsely predicting positive (FP). F2 (β=2): recall has 4× the weight of precision. Medical screening (cancer, sepsis, rare disease): better to have a false alarm (FP → unnecessary follow-up test) than to miss a true case (FN → missed diagnosis). Fraud detection (some applications): better to flag more suspicious transactions than to miss fraud. β < 1: precision is more heavily weighted. F0.5: useful when false positives are costly: spam filtering (FP = important email in spam → very costly); legal/compliance decisions.