The F2 score in machine learning weights recall twice as heavily as precision. Get the formula, a worked example, sklearn code, and when to use F2 over F1.

Updated August 2026
Make a fraud model a little more willing to raise an alarm, and two standard scoring metrics will disagree about whether it just got better or worse. One marks the model down; the other barely reacts. Neither is wrong. F1 and F2 score the same predictions against different ideas of what a mistake costs, and that difference is the reason the F2 score exists.
Quick answer: The F2 score is a machine learning classification metric that combines precision and recall. It weights recall twice as heavily as precision, so it rewards models that catch nearly every positive case, even at the cost of more false positives. The formula is F2 = (5 × precision × recall) / (4 × precision + recall).
The F2 score, also written F2-score and sometimes called the F2 measure or F2 metric, is a member of the F-beta family of classification metrics, with beta set to 2. In that family, beta is the ratio of recall importance to precision importance: scikit-learn's documentation puts it as "beta = 2 makes recall twice as important as precision."
Where the F1 score asks whether a model balances its two error types, the F2 score asks a sharper question: does the model miss things? A missed positive (a false negative) hurts an F2 score roughly four times as much as a false alarm of the same size. That makes F2 the natural metric when letting a case slip through costs far more than reviewing one flagged by mistake.
The F2 score formula is:
F2 = 5 × (precision × recall) / (4 × precision + recall)
It comes from the general F-beta formula with beta = 2:
Fβ = (1 + β²) × (precision × recall) / (β² × precision + recall)
Written in raw counts, the same score is F2 = 5TP / (5TP + FP + 4FN), where TP is true positives, FP false positives, and FN false negatives. This form makes the weighting visible: each false negative counts four times as much as each false positive.

Calculate an F2 score from the confusion matrix: get precision and recall, then apply the formula. Suppose a screening model finds 80 of 100 true positive cases (misses 20) and raises 40 false alarms. Precision is 80 / (80 + 40) = 0.667 and recall is 80 / (80 + 20) = 0.80.
| Measure | Formula | Result |
|---|---|---|
| Precision | TP / (TP + FP) | 0.667 |
| Recall | TP / (TP + FN) | 0.80 |
| F2 score | 5PR / (4P + R) | 0.769 |
Now lower the threshold so the model finds 95 of the 100 cases, at the cost of 120 false alarms. Precision falls to 0.442 while recall rises to 0.95. The F1 score punishes that trade, dropping from 0.727 to 0.603. The F2 score holds at 0.772. If those 15 extra catches are early disease diagnoses, F2 scores the model the way the clinic would.

In Python, scikit-learn's fbeta_score function returns the F2 score directly when you pass beta=2:
from sklearn.metrics import fbeta_score
f2 = fbeta_score(y_true, y_pred, beta=2)To use F2 as the optimization target in cross-validation or a grid search, wrap it in a scorer:
from sklearn.metrics import fbeta_score, make_scorer
ftwo_scorer = make_scorer(fbeta_score, beta=2)One edge case worth knowing: when a model makes no positive predictions, the score is undefined, and fbeta_score returns 0 with a warning by default. The zero_division parameter controls that behavior.
Use the F2 score when a false negative costs clearly more than a false positive. Medical screening, fraud triage, safety alerts, and content-moderation queues share the same shape: a miss becomes an untreated patient, an unrecovered loss, or an unreviewed incident, while a false alarm becomes a review task. When the review queue is cheap and the miss is expensive, F2 matches the decision better than F1.
The metric cannot set that cost ratio for you. Choosing beta = 2 asserts that recall matters twice as much as precision, and nothing in the data proves the true ratio is 2 rather than 3 or 1.5. Treat beta as a product decision, made by whoever owns the cost of each error, and write it down before tuning begins.
Keep the objective function distinction in view too. F2 is an evaluation metric applied after a threshold turns scores into decisions, not the target a model optimizes during training.
The F2 score tells you how completely a model finds the positive class, penalizing false alarms only lightly. The 0.769 from the worked example above says the model catches most true cases while keeping false alarms tolerable, with the balance tipped toward catching. Read it as a recall-leaning summary, not a balanced one.
Two levers move the score. Raising recall lifts it more than an equal gain in precision does, by design, and a precision drop moves the score roughly a quarter as much as an equal recall drop.
The score stays silent on three things. It ignores true negatives, so it says nothing about the negative class. It scores decisions after a threshold, not whether the model's confidence scores are calibrated, so a model can post a strong F2 while its probabilities run far from reality. And one number hides the confusion matrix beneath it, where two very different models can share a score.
F0.5 is the F2 score's mirror image: it weights precision twice as heavily as recall, for cases where a false alarm costs more than a miss. A spam filter is the classic case, since hiding one legitimate email hurts more than letting one spam message through. F1 sits between them, weighting both errors equally. Beta itself can be any positive number, and the emphasis scales with its square: F3 weights recall nine times as heavily as precision, for the rare case where a miss is catastrophic.
On the same confusion matrix (80 true positives, 20 misses, 40 false alarms), the three scores order themselves by what they punish:
| Metric | Weighting | Score |
|---|---|---|
| F0.5 | Precision counts double | 0.690 |
| F1 | Equal weight | 0.727 |
| F2 | Recall counts double | 0.769 |
Recall (0.80) exceeds precision (0.667) here, so the metric that favors recall reads highest. The model didn't change between the rows. Only the definition of a costly mistake did.
For multi-class classification, calculate F2 per class and then average the results. The fbeta_score function exposes this through its average parameter: macro gives each class equal weight, micro pools every decision before scoring, and weighted averages the per-class scores by support. These are the same averaging modes documented for the F1 score, applied with beta set to 2. Macro F2 is the one to watch when the rare class is the one you most need to catch.
The F2 score can be gamed by predicting almost everything positive. A model that flags every case scores a perfect recall of 1.0, and if 20% of the data is positive, its precision floor is 0.20. That useless model still posts an F2 score of 0.56. Always read the confusion matrix next to the score, and compare against the flag-everything baseline before celebrating.
Two other mistakes carry over from every classification metric. Reporting F2 on training data flatters the model; use held-out data the threshold was not tuned on. And the score is only as honest as its ground truth, which makes data labeling quality part of the evaluation, not a separate concern. Google's classification guide shows how moving the threshold trades precision against recall; F2 simply decides how that trade is scored.
There is no universal threshold for a good F2 score. The score runs from 0 to 1, and its value depends on class balance and the flag-everything baseline. A 0.75 can be strong where positives are rare and weak where they are common. Compare against a baseline on the same held-out data rather than against a fixed number.
The F1 and F2 scores use the same inputs, precision and recall, but weight them differently. F1 weights both equally. F2 weights recall twice as heavily, so it penalizes missed positives about four times as hard as false alarms. A recall-heavy model scores higher on F2 than on F1; a precision-heavy model scores lower.
A higher F2 score is better. The score runs from 0, where precision or recall is zero, to 1, where the model finds every positive case and every flag is correct. Higher is only meaningful within a comparison, though: judge a score against a baseline on the same data and threshold, not in isolation.
Yes, scikit-learn supports the F2 score directly: fbeta_score with beta=2 computes it, and make_scorer turns it into a cross-validation scorer. There is no separate F2 function to install or write by hand.
This content was generated with the assistance of AI. Our AI prompt chain workflow is carefully grounded and preferences .gov and .edu citations when available. All content is reviewed by a Telnyx employee to ensure accuracy, relevance, and a high standard of quality.