F-score

From HandWiki
Short description: Statistical measure of a test's accuracy
Precision and recall

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 [math]\displaystyle{ F_\beta }[/math] 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 either precision or recall are 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).[1]

Definition

The traditional F-measure or balanced F-score (F1 score) is the harmonic mean of precision and recall:[2]

[math]\displaystyle{ F_1 = \frac{2}{\mathrm{recall}^{-1} + \mathrm{precision}^{-1}} = 2 \frac{\mathrm{precision} \cdot \mathrm{recall}}{\mathrm{precision} + \mathrm{recall}} = \frac{2\mathrm{tp}}{2\mathrm{tp} + \mathrm{fp} + \mathrm{fn}} }[/math].

Fβ score

A more general F score, [math]\displaystyle{ F_\beta }[/math], that uses a positive real factor [math]\displaystyle{ \beta }[/math], where [math]\displaystyle{ \beta }[/math] is chosen such that recall is considered [math]\displaystyle{ \beta }[/math] times as important as precision, is:

[math]\displaystyle{ F_\beta = (1 + \beta^2) \cdot \frac{\mathrm{precision} \cdot \mathrm{recall}}{(\beta^2 \cdot \mathrm{precision}) + \mathrm{recall}} }[/math].

In terms of Type I and type II errors this becomes:

[math]\displaystyle{ F_\beta = \frac {(1 + \beta^2) \cdot \mathrm{true\ positive} }{(1 + \beta^2) \cdot \mathrm{true\ positive} + \beta^2 \cdot \mathrm{false\ negative} + \mathrm{false\ positive}}\, }[/math].

Two commonly used values for [math]\displaystyle{ \beta }[/math] are 2, which weighs recall higher than precision, and 0.5, which weighs recall lower than precision.

The F-measure was derived so that [math]\displaystyle{ F_\beta }[/math] "measures the effectiveness of retrieval with respect to a user who attaches [math]\displaystyle{ \beta }[/math] times as much importance to recall as precision".[3] It is based on Van Rijsbergen's effectiveness measure

[math]\displaystyle{ E = 1 - \left(\frac{\alpha}{p} + \frac{1-\alpha}{r}\right)^{-1} }[/math].

Their relationship is [math]\displaystyle{ F_\beta = 1 - E }[/math] where [math]\displaystyle{ \alpha=\frac{1}{1 + \beta^2} }[/math].

Diagnostic testing

This is related to the field of binary classification where recall is often termed "sensitivity".

Normalised harmonic mean plot where x is precision, y is recall and the vertical axis is F1 score, in percentage points
Precision-Recall Curve: points from different thresholds are color coded, the point with optimal F-score is highlighted in red

Dependence of the F-score on class imbalance

Precision-recall curve, and thus the [math]\displaystyle{ F_\beta }[/math] score, explicitly depends on the ratio [math]\displaystyle{ r }[/math] of positive to negative test cases.[4] 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, 2020[5] ) is to use a standard class ratio [math]\displaystyle{ r_0 }[/math] 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.[6] 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[7] and so [math]\displaystyle{ F_\beta }[/math] is seen in wide application.

The F-score is also used in machine learning.[8] 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.[9]

The F-score has been widely used in the natural language processing literature,[10] 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.[11]

  • The F-score of a classifier with always predicts the positive class converges to 1 as the probability of the positive class increases.
  • The F-score of a classifier with always predicts the positive class is equal to the precision.
  • 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.
  • F-1 is concave in the true positive rate.[12]

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.[13]

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.[14]

David 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.[15]

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.[16]

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.[17]

Extension to multi-class classification

The F-score is also used for evaluating classification problems with more than two classes (Multiclass classification). In this setup, the final score is obtained by micro-averaging (biased by class frequency) or macro-averaging (taking all classes as equally important). For macro-averaging, two different formulas have been used by applicants: the F-score of (arithmetic) class-wise precision and recall means or the arithmetic mean of class-wise F-scores, where the latter exhibits more desirable properties.[18]

See also

References

  1. Sasaki, Y. (2007). "The truth of the F-measure". https://www.toyota-ti.ac.jp/Lab/Denshi/COIN/people/yutaka.sasaki/F-measure-YS-26Oct07.pdf. 
  2. Aziz Taha, Abdel (2015). "Metrics for evaluating 3D medical image segmentation: analysis, selection, and tool". BMC Medical Imaging 15 (29): 1–28. doi:10.1186/s12880-015-0068-x. PMID 26263899. 
  3. Van Rijsbergen, C. J. (1979). Information Retrieval (2nd ed.). Butterworth-Heinemann. http://www.dcs.gla.ac.uk/Keith/Preface.html. 
  4. Brabec, Jan; Komárek, Tomáš; Franc, Vojtěch; Machlica, Lukáš (2020). "On model evaluation under non-constant class imbalance". Springer. pp. 74–87. doi:10.1007/978-3-030-50423-6_6. 
  5. Siblini, W.; Fréry, J.; He-Guelton, L.; Oblé, F.; Wang, Y. Q. (2020). "Master your metrics with calibration". in M. Berthold. Springer. pp. 457–469. doi:10.1007/978-3-030-44584-3_36. 
  6. Beitzel., Steven M. (2006). On Understanding and Classifying Web Queries (Ph.D. thesis). IIT. CiteSeerX 10.1.1.127.634.
  7. X. Li; Y.-Y. Wang; A. Acero (July 2008). "Learning query intent from regularized click graphs". p. 339. doi:10.1145/1390334.1390393. ISBN 9781605581644. 
  8. See, e.g., the evaluation of the [1].
  9. Powers, David M. W (2015). "What the F-measure doesn't measure". arXiv:1503.06410 [cs.IR].
  10. Derczynski, L. (2016). "Complementarity, F-score, and NLP Evaluation". https://www.aclweb.org/anthology/L16-1040. 
  11. Manning, Christopher (April 1, 2009). An Introduction to Information Retrieval. Exercise 8.7: Cambridge University Press. p. 200. https://nlp.stanford.edu/IR-book/pdf/irbookonlinereading.pdf. Retrieved 18 July 2022. 
  12. Lipton, Z.C., Elkan, C.P., & Narayanaswamy, B. (2014). F1-Optimal Thresholding in the Multi-Label Setting. ArXiv, abs/1402.1892.
  13. Hand, David (in en). A note on using the F-measure for evaluating record linkage algorithms - Dimensions. doi:10.1007/s11222-017-9746-6. https://app.dimensions.ai/details/publication/pub.1084928040. Retrieved 2018-12-08. 
  14. "The advantages of the Matthews correlation coefficient (MCC) over F1 score and accuracy in binary classification evaluation". BMC Genomics 21 (6): 6. January 2020. doi:10.1186/s12864-019-6413-7. PMID 31898477. 
  15. Powers, David M W (2011). "Evaluation: From Precision, Recall and F-Score to ROC, Informedness, Markedness & Correlation". Journal of Machine Learning Technologies 2 (1): 37–63. 
  16. Sitarz, Mikolaj (2022). "Extending F1 metric, probabilistic approach". arXiv:2210.11997 [cs.LG].
  17. "Classification assessment methods". Applied Computing and Informatics 17: 168–192. August 2018. doi:10.1016/j.aci.2018.08.003. 
  18. J. Opitz; S. Burst (2019). "Macro F1 and Macro F1". arXiv:1911.03347 [stat.ML].

de:Beurteilung eines Klassifikators#Kombinierte Maße