F-score
{{short description|Statistical measure of a test's accuracy}}
{{For|the significance test|F-test}}
In statistical analysis of binary classification and information retrieval systems, the F-score or F-measure is a measure of predictive performance. It is calculated from the precision and recall of the test, where the precision is the number of true positive results divided by the number of all samples predicted to be positive, including those not identified correctly, and the recall is the number of true positive results divided by the number of all samples that should have been identified as positive. Precision is also known as positive predictive value, and recall is also known as sensitivity in diagnostic binary classification.
The F1 score is the harmonic mean of the precision and recall. It thus symmetrically represents both precision and recall in one metric. The more generic score applies additional weights, valuing one of precision or recall more than the other.
The highest possible value of an F-score is 1.0, indicating perfect precision and recall, and the lowest possible value is 0, if the precision or the recall is zero.
Etymology
The name F-measure is believed to be named after a different F function in Van Rijsbergen's book, when introduced to the Fourth Message Understanding Conference (MUC-4, 1992).{{Cite news
| last1 = Sasaki
| first1 = Y.
| year = 2007
| title = The truth of the F-measure
| journal = Teach Tutor Mater
| volume = 1
| issue = 5
| pages = 1–5
| url=https://nicolasshu.com/assets/pdf/Sasaki_2007_The%20Truth%20of%20the%20F-measure.pdf }}
Definition
The traditional F-measure or balanced F-score (F1 score) is the harmonic mean of precision and recall:{{Cite journal
| last1 = Aziz Taha
| first1 = Abdel
| year = 2015
| title = Metrics for evaluating 3D medical image segmentation: analysis, selection, and tool
| journal = BMC Medical Imaging
| volume = 15
| issue = 29
| pages = 1–28
| doi = 10.1186/s12880-015-0068-x
| pmid = 26263899
| pmc = 4533825
| doi-access = free}}
:
With {{math|1=precision = TP / (TP + FP)}} and {{math|1=recall = TP / (TP + FN)}}, it follows that the numerator of {{math|F{{sub|1}}}} is the sum of their numerators and the denominator of {{math|F{{sub|1}}}} is the sum of their denominators.
= F<sub>β</sub> score =
A more general F score, , that uses a positive real factor , where is chosen such that recall is considered times as important as precision, is:
:
In terms of Type I and type II errors this becomes:
:
Two commonly used values for are 2, which weighs recall higher than precision, and 0.5, which weighs recall lower than precision.
The F-measure was derived so that "measures the effectiveness of retrieval with respect to a user who attaches times as much importance to recall as precision".{{cite book | last = Van Rijsbergen | first = C. J. | url=http://www.dcs.gla.ac.uk/Keith/Preface.html|year = 1979 | title = Information Retrieval | edition= 2nd | publisher=Butterworth-Heinemann }} It is based on Van Rijsbergen's effectiveness measure
:
Their relationship is: where
Diagnostic testing
This is related to the field of binary classification where recall is often termed "sensitivity".
{{diagnostic testing diagram}}
Dependence of the F-score on class imbalance
Precision-recall curve, and thus the score, explicitly depends on the ratio
of positive to negative test cases.
{{cite conference
| title = On model evaluation under non-constant class imbalance
| last1 = Brabec
| first1 = Jan
| last2 = Komárek
| first2 = Tomáš
| last3 = Franc
| first3 = Vojtěch
| last4 = Machlica
| first4 = Lukáš
| book-title = International Conference on Computational Science
| pages = 74–87
| year = 2020
| publisher = Springer
| doi = 10.1007/978-3-030-50423-6_6
| arxiv=2001.05571
| doi-access = free
}}
This means that comparison of the
F-score across different problems with differing class ratios is
problematic. One way to address this issue (see e.g., Siblini et al.,
{{cite conference
| title = Master your metrics with calibration
| last1 = Siblini
| first1 = W.
| last2 = Fréry
| first2 = J.
| last3 = He-Guelton
| first3 = L.
| last4 = Oblé
| first4 = F.
| last5 = Wang
| first5 = Y. Q.
| date = 2020
| editor= M. Berthold |editor2=A. Feelders |editor3=G. Krempl
| publisher = Springer
| book-title = Advances in Intelligent Data Analysis XVIII
| pages = 457–469
| doi = 10.1007/978-3-030-44584-3_36
| arxiv=1909.02827
| doi-access = free
}}
) is to use a standard class ratio when making such comparisons.
Applications
The F-score is often used in the field of information retrieval for measuring search, document classification, and query classification performance.{{cite thesis | first=Steven M. |last=Beitzel. |citeseerx = 10.1.1.127.634 | title=On Understanding and Classifying Web Queries | degree=Ph.D. | publisher=IIT | year= 2006}} It is particularly relevant in applications which are primarily concerned with the positive class and where the positive class is rare relative to the negative class.
Earlier works focused primarily on the F1 score, but with the proliferation of large scale search engines, performance goals changed to place more emphasis on either precision or recall{{cite conference |author1=X. Li |author2=Y.-Y. Wang |author3=A. Acero |s2cid=8482989 | title=Learning query intent from regularized click graphs | work= Proceedings of the 31st SIGIR Conference |date=July 2008|page=339 |doi=10.1145/1390334.1390393 |isbn=9781605581644 }} and so is seen in wide application.
The F-score is also used in machine learning.See, e.g., the evaluation of the [https://dl.acm.org/citation.cfm?id=1119195]. However, the F-measures do not take true negatives into account, hence measures such as the Matthews correlation coefficient, Informedness or Cohen's kappa may be preferred to assess the performance of a binary classifier.{{cite arXiv |eprint=1503.06410|title=What the F-measure doesn't measure|last1=Powers|first1=David M. W|class=cs.IR|year=2015}}
The F-score has been widely used in the natural language processing literature,{{cite conference |first=L. |last=Derczynski | url= https://www.aclweb.org/anthology/L16-1040 | title= Complementarity, F-score, and NLP Evaluation | work= Proceedings of the International Conference on Language Resources and Evaluation| date= 2016}} such as in the evaluation of named entity recognition and word segmentation.
Properties
The F1 score is the Dice coefficient of the set of retrieved items and the set of relevant items.{{cite book |last1=Manning |first1=Christopher |title=An Introduction to Information Retrieval |date=April 1, 2009 |publisher=Cambridge University Press |location=Exercise 8.7 |page=200 |url=https://nlp.stanford.edu/IR-book/pdf/irbookonlinereading.pdf |access-date=18 July 2022}}
- The F1-score of a classifier which always predicts the positive class converges to 1 as the probability of the positive class increases.
- The F1-score of a classifier which always predicts the positive class is equal to 2 * proportion_of_positive_class / ( 1 + proportion_of_positive_class ), since the recall is 1, and the precision is equal to the proportion of the positive class.{{cite web | url=https://stats.stackexchange.com/q/390541 | title=What is the baseline of the F1 score for a binary classifier? }}
- If the scoring model is uninformative (cannot distinguish between the positive and negative class) then the optimal threshold is 0 so that the positive class is always predicted.
- F1 score is concave in the true positive rate.{{cite arXiv | eprint=1402.1892 | author1=Zachary Chase Lipton | last2=Elkan | first2=Charles | last3=Narayanaswamy | first3=Balakrishnan | title=Thresholding Classifiers to Maximize F1 Score | date=2014 | class=stat.ML }}
Criticism
David Hand and others criticize the widespread use of the F1 score since it gives equal importance to precision and recall. In practice, different types of mis-classifications incur different costs. In other words, the relative importance of precision and recall is an aspect of the problem.{{Cite journal|url=https://app.dimensions.ai/details/publication/pub.1084928040|title=A note on using the F-measure for evaluating record linkage algorithms - Dimensions|last=Hand|first=David|website=app.dimensions.ai|date=May 2018 |volume=28 |issue=3 |pages=539–547 |language=en|access-date=2018-12-08|doi=10.1007/s11222-017-9746-6|hdl=10044/1/46235|s2cid=38782128|hdl-access=free}}
According to Davide Chicco and Giuseppe Jurman, the F1 score is less truthful and informative than the Matthews correlation coefficient (MCC) in binary evaluation classification.{{cite journal
| vauthors = Chicco D, Jurman G
| title = The advantages of the Matthews correlation coefficient (MCC) over F1 score and accuracy in binary classification evaluation
| journal = BMC Genomics
| volume = 21
| issue = 6
| pages = 6
| date = January 2020
| pmid = 31898477
| doi = 10.1186/s12864-019-6413-7
| pmc= 6941312
| doi-access = free
}}
David M W Powers has pointed out that F1 ignores the True Negatives and thus is misleading for unbalanced classes, while kappa and correlation measures are symmetric and assess both directions of predictability - the classifier predicting the true class and the true class predicting the classifier prediction, proposing separate multiclass measures Informedness and Markedness for the two directions, noting that their geometric mean is correlation.{{cite journal |first=David M W |last=Powers |date=2011 |title=Evaluation: From Precision, Recall and F-Score to ROC, Informedness, Markedness & Correlation |journal=Journal of Machine Learning Technologies |volume=2 |issue=1 |pages=37–63 |hdl=2328/27165 }}
Another source of critique of F1 is its lack of symmetry. It means it may change its value when dataset labeling is changed - the "positive" samples are named "negative" and vice versa.
This criticism is met by the P4 metric definition, which is sometimes indicated as a symmetrical extension of F1.{{cite journal | arxiv=2210.11997| last1=Sitarz| first1=Mikolaj| title=Extending F1 Metric, Probabilistic Approach| journal=Advances in Artificial Intelligence and Machine Learning| year=2023| volume=03| issue=2| pages=1025–1038| doi=10.54364/AAIML.2023.1161}}
Finally, Ferrer{{cite journal
| vauthors = Ferrer L
| title = No Need for Ad-hoc Substitutes: The Expected Cost is a Principled All-purpose Classification Metric
| journal = Transactions on Machine Learning Research
| date = February 2025
| url = https://openreview.net/pdf?id=5PPbvCExZs
}}
and Dyrland et al.{{cite arXiv
| vauthors = Dyrland K, Lundervold AS, Porta Mana P
| title = Does the evaluation stand up to evaluation? A first-principle approach to the evaluation of classifiers
| eprint=2302.12006
| date = May 2022
}}
argue that the expected cost (or its counterpart, the expected utility) is the only principled metric for evaluation of classification decisions, having various advantages over the F-score and the MCC. Both works show that the F-score can result in wrong conclusions about the absolute and relative quality of systems. In a similar vein, Marwah et al.{{Cite conference
|vauthors = Marwah M, Narayanan A, Jou S, Arlitt M, Pospelova M
|year=2024
|title=Is F1 Score Suboptimal for Cybersecurity Models? Introducing Cscore, a Cost-Aware Alternative for Model Assessment
|url=https://ceur-ws.org/Vol-3920/paper11.pdf
|conference=Proceedings of the Conference on Applied Machine Learning in Information Security {(CAMLIS} 2024), Arlington, Virginia, USA, October 24-25, 2024
|publisher=CEUR-WS.org
|volume=3920
|pages=190--209}}
propose a new cost-based metric called Cscore which incorporates cost considerations while being defined in terms of precision and recall, similar to F1 score.
Difference from Fowlkes–Mallows index
While the F-measure is the harmonic mean of recall and precision, the Fowlkes–Mallows index is their geometric mean.
{{cite journal
| vauthors = Tharwat A
| title = Classification assessment methods
| journal = Applied Computing and Informatics
| date = August 2018
| volume = 17
| pages = 168–192
| doi = 10.1016/j.aci.2018.08.003| doi-access = free
}}
Extension to multi-class classification
The F-score is also used for evaluating classification problems with more than two classes (Multiclass classification). A common method is to average the F-score over each class, aiming at a balanced measurement of performance.{{cite journal|last=Opitz|first=Juri|title=A Closer Look at Classification Evaluation Metrics and a Critical Reflection of Common Evaluation Practice|journal=Transactions of the Association for Computational Linguistics|date=2024|volume=12|pages=820–836|doi=10.1162/tacl_a_00675|url=https://doi.org/10.1162/tacl_a_00675|arxiv=2404.16958}}
=Macro F1=
Macro F1 is a macro-averaged F1 score aiming at a balanced performance measurement. To calculate macro F1, two different averaging-formulas have been used: the F1 score of (arithmetic) class-wise precision and recall means or the arithmetic mean of class-wise F1 scores, where the latter exhibits more desirable properties.{{cite arXiv | author1 = J. Opitz | author2 = S. Burst | year = 2019 | title = Macro F1 and Macro F1 | eprint=1911.03347 |class=stat.ML }}
=Micro F1=
Micro F1 is the harmonic mean of micro precision and micro recall. In single-label multi-class classification, micro precision equals micro recall, thus micro F1 is equal to both. However, contrary to a common misconception, micro F1 does not generally equal accuracy, because accuracy takes true negatives into account while micro F1 does not.{{Cite book
|last=Brownlee
|first=Jason
|title=Imbalanced Classification with Python: Better Metrics, Balance Skewed Classes, Cost-Sensitive Learning
|date=7 September 2021
|publisher=Machine Learning Mastery
|isbn=979-8468452240
|language=en
|page=40
|chapter=4.3 – Micro F1 Score
}}
See also
- BLEU
- Confusion matrix
- Hypothesis tests for accuracy
- METEOR
- NIST (metric)
- Receiver operating characteristic
- ROUGE (metric)
- Uncertainty coefficient, aka Proficiency
- Word error rate
- LEPOR
{{Machine learning evaluation metrics}}