In statistical analysis of binary classification, the F1 score (or F-score or F-measure) is a measure of a test’s accuracy that is based on both precision and recall, which are defined as follows:
- Precision, p, is the number of observations that are correctly classified as positive divided by the number of observations that are classified as positive.
- Recall, r, is the number of observations that are correctly classified as positive divided by the number of observations that are positive.
The F1 score can be interpreted as a weighted average of precision and recall, whose best value is 1 and worst value is 0.
The traditional F1 score is the harmonic mean of precision and recall:
F =2*p*r / (p+r)
The FMeasure function is not restricted to binary classification.
The general formula for a positive real β is:
Fβ =(1+β*β)*p*r /(β*β*p+r)