induwara.lk
induwara.lkMachine Learning · Metrics

F-beta Score Calculator — F1, F2, F0.5

Compute the F-beta score of a binary classifier from precision and recall or from raw confusion-matrix counts (TP, FP, FN). Presets for F1, F2, and F0.5, plus any custom beta — with F0.5, F1, and F2 shown side by side. Uses the exact scikit-learn formula.

By Induwara AshinsanaUpdated Jul 13, 2026
F-beta scoreF1 · F2 · F0.5 · any β
scikit-learn formula
Values as
Presets
Try an example
F1 score
0.7467
74.67%
Precision
0.8000
80%
Recall
0.7000
70%

F0.5 vs F1 vs F2

F0.5
0.7778
F1
0.7467
F2
0.7179

β = 1 weights precision and recall equally (the harmonic mean). Your precision is higher, so raising β would push the score up and lowering β would push it down.

Formula and edge-case conventions from the scikit-learn fbeta_score reference and Van Rijsbergen's F-measure. When precision = recall = 0, the score is defined as 0.

How it works

The F-beta score is a single number that blends precision (of the items the model flagged positive, how many really were) and recall (of the real positives, how many the model caught). The parameter beta decides how much more recall matters than precision. This tool implements the formula exactly as scikit-learn's fbeta_score does, which traces back to Van Rijsbergen's effectiveness measure (1979) and Chinchor's MUC-4 F-measure (1992).

If you enter confusion-matrix counts, precision and recall are derived first:

  • precision = TP / (TP + FP)
  • recall = TP / (TP + FN)

The F-beta score itself uses the precision/recall form:

F_beta = (1 + β²) · (precision · recall) / (β² · precision + recall)

To make the result trustworthy, the calculator also computes it a second way — straight from the counts — and confirms the two agree to full floating-point precision:

F_beta = (1 + β²) · TP / ((1 + β²) · TP + β² · FN + FP)

Beta controls the trade-off. With β = 1 the two contributions are equal and F1 is the harmonic mean of precision and recall. With β = 2 recall is weighted twice as heavily as precision, so F2 rises when a model catches more true positives — the reason it is preferred for screening tasks. With β = 0.5 precision is weighted twice as heavily, so F0.5 rewards models that avoid false alarms. When precision and recall are equal, every F-score is identical no matter the beta.

One edge case matters: if precision and recall are both zero (no true positives), the denominator is zero. Rather than return an undefined value, the tool follows the scikit-learn convention and reports a score of 0, so the number is always safe to use in a pipeline. Scores display to four decimal places, but the underlying math keeps full precision.

Worked examples

Recall slightly above precision

TP = 80, FP = 20, FN = 10

  1. precision = 80 / (80 + 20) = 0.8000
  2. recall = 80 / (80 + 10) = 0.8889
  3. F1 = 2·0.8·0.8889 / (0.8 + 0.8889) = 160/190 = 0.8421
  4. F2 = 5·0.8·0.8889 / (4·0.8 + 0.8889) = 400/460 = 0.8696
  5. F0.5 = 1.25·0.8·0.8889 / (0.25·0.8 + 0.8889) = 100/122.5 = 0.8163
  6. Recall > precision, so F0.5 < F1 < F2.

High precision, low recall

precision = 0.9, recall = 0.3

  1. F1 = 2·0.9·0.3 / (0.9 + 0.3) = 0.54/1.2 = 0.4500
  2. F2 = 5·0.9·0.3 / (4·0.9 + 0.3) = 1.35/3.9 = 0.3462
  3. F0.5 = 1.25·0.9·0.3 / (0.25·0.9 + 0.3) = 0.3375/0.525 = 0.6429
  4. Precision > recall, so the order flips: F2 < F1 < F0.5.

Medical screening — recall is what matters

TP = 45, FP = 150, FN = 5

  1. precision = 45 / (45 + 150) = 0.2308
  2. recall = 45 / (45 + 5) = 0.9000
  3. F1 (counts) = 2·45 / (2·45 + 1·5 + 150) = 90/245 = 0.3673
  4. F2 (counts) = 5·45 / (5·45 + 4·5 + 150) = 225/395 = 0.5696
  5. F2 rewards the high-recall screener that F1 undervalues.

Frequently asked questions

Sources & references

Formulas and edge-case conventions on this page were last cross-checked against the scikit-learn documentation on 2026-07-13. Both computation paths — precision/recall and confusion-matrix — are verified to agree for every worked example above.

Related tools

Rate this tool
Be the first to rate

Comments & feedback

Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.

Found a bug, edge case, or want to suggest an improvement?

Email me at [email protected] — most fixes ship within 24 hours.