Telnyx - Global Communications Platform ProviderHome
Voice AI AgentsText-to-SpeechSpeech-to-TextEmbeddingsSearch APIBrowser APIMeetingBotVoice DesignInference APIAgentSDKFunctionsStateful ActorsKVSQLDBStorageGlobal NumbersVoice APISIP TrunkingSMS APIEmail APIRCSWhatsAppWebRTCVerify APINumber ReputationNumber LookupDeepfake DetectionBranded CallingIoT SIMeSIMMobile VoicePrivate Wireless GatewaysVirtual Cross ConnectsCloud VPNGlobal IP200+ open-source buildsagent-signup.mdx402View all primitivesHealthcareFinanceTravel and HospitalityLogistics and TransportationContact CenterInsuranceRetail and E-CommerceSales and MarketingServices and DiningView all solutionsVoice AIVoice APIInferenceMobile VoiceSpeech-to-TextText-to-SpeechSIP TrunkingSMS APIEmail APIWhatsApp Business APIGlobal NumbersIoT SIM CardView all pricingOur NetworkGlobal communicationsEdge ComputeAgents PlatformPartnersCareersCustomer storiesResource centerMission Control PortalEventsSupport centerSETIDev DocsIntegrationsCode examples
Contact usLog in
Contact usLog inSign up

Social

Company

  • Our Network
  • Global Coverage
  • Release Notes
  • Careers
  • Voice AI
  • AI Glossary
  • Shop

Legal

  • Data and Privacy
  • Report Abuse
  • Privacy Policy
  • Cookie Policy
  • Law Enforcement
  • Acceptable Use
  • Trust Center
  • Country Specific Requirements
  • Website Terms and Conditions
  • Terms and Conditions of Service

Compare

  • ElevenLabs
  • Vapi
  • Baseten
  • Together.ai
  • Twilio
  • Bandwidth
  • Vonage
  • Amazon Connect
  • Cloudflare
© Telnyx LLC 2026
ISO • PCI • HIPAA • GDPR • SOC2 Type II
Back to Glossary

F2 Score: Formula, Example, and When to Use It Over F1

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.

Andy Muns
Editor: Andy Muns

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).

What is the F2 score?

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.

What is the F2 score formula?

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.

The F2 score formula shown as F-beta with beta set to 2: F2 = 5 times precision times recall divided by (4 times precision plus recall), with the raw-count form F2 = 5TP / (5TP + FP + 4FN), so each false negative counts four times as much as each false positive.

How do you calculate an F2 score?

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.

MeasureFormulaResult
PrecisionTP / (TP + FP)0.667
RecallTP / (TP + FN)0.80
F2 score5PR / (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.

Loosening a model's decision threshold: true positives rise from 80 to 95 and false alarms from 40 to 120 on the same 100 true cases, so the F1 score drops from 0.727 to 0.603 while the F2 score holds, moving from 0.769 to 0.772.

How do you calculate the F2 score in Python with sklearn?

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.

When should you use the F2 score instead of F1?

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.

What does the F2 score tell you?

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.

What are F0.5 and other F-beta scores?

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:

MetricWeightingScore
F0.5Precision counts double0.690
F1Equal weight0.727
F2Recall counts double0.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.

How do you calculate F2 for multi-class problems?

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.

What mistakes make an F2 score misleading?

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.

Frequently asked questions

What is a good F2 score?

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.

What is the difference between the F1 and F2 score?

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.

Is a higher or lower F2 score better?

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.

Does scikit-learn support the F2 score?

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.

Sources

  • scikit-learn. fbeta_score documentation.
  • Google Machine Learning Crash Course. Classification: Accuracy, recall, precision, and related metrics.
Share on Social

Jump to:

What is the F2 score?What is the F2 score formula?How do you calculate an F2 score?How do you calculate the F2 score in Python with sklearn?When should you use the F2 score instead of F1?What does the F2 score tell you?What are F0.5 and other F-beta scores?How do you calculate F2 for multi-class problems?What mistakes make an F2 score misleading?Frequently asked questionsSources

Sign up for emails of our latest articles and news

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.

Sign up and start building.

Sign UpContact Us

Ask AI

  • GPT
  • Claude
  • Perplexity
  • Gemini
  • Grok