Skip to content

F Score

  • Measures classification performance by combining precision and recall into a single score.
  • Uses a parameter beta to weight the relative importance of precision versus recall (beta = 1 gives equal weight).
  • Commonly reported per class and can be aggregated to summarize overall model performance.

F-score is a metric used to evaluate the performance of a model in classification tasks. It is a weighted average of precision and recall. Precision is the number of true positives divided by the sum of true positives and false positives, and recall is the number of true positives divided by the sum of true positives and false negatives. The F-score is calculated using the following formula:

F-score=(1+β2)(precisionrecall)β2precision+recallF\text{-score} = \frac{(1 + \beta^2)\cdot(\text{precision}\cdot\text{recall})}{\beta^2\cdot\text{precision} + \text{recall}}

Precision and recall (as defined in the source) can be written:

precision=true positivestrue positives+false positives\text{precision} = \frac{\text{true positives}}{\text{true positives} + \text{false positives}} recall=true positivestrue positives+false negatives\text{recall} = \frac{\text{true positives}}{\text{true positives} + \text{false negatives}}
  • The parameter beta controls the relative weight of recall versus precision. When beta = 1, precision and recall are weighted equally.
  • By combining precision and recall, the F-score provides a single-number summary that accounts for both false positives and false negatives.
  • Different beta values shift importance toward precision (beta < 1) or recall (beta > 1) according to application requirements.

Confusion matrix (as given in the source):

Actual CatActual Dog
Predicted Cat4010
Predicted Dog2030

Based on this confusion matrix, the source calculates precision and recall for each class:

  • Precision for cats: 40 / (40 + 20) = 0.67

  • Recall for cats: 40 / (40 + 10) = 0.80

  • Precision for dogs: 30 / (30 + 20) = 0.60

  • Recall for dogs: 30 / (30 + 10) = 0.75

Using beta = 1 in the F-score formula, the source gives:

  • F-score for cats:

    (1+12)(0.670.80)/(120.67+0.80)=0.73(1 + 1^2)\cdot(0.67 \cdot 0.80) / (1^2 \cdot 0.67 + 0.80) = 0.73
  • F-score for dogs:

    (1+12)(0.600.75)/(120.60+0.75)=0.68(1 + 1^2)\cdot(0.60 \cdot 0.75) / (1^2 \cdot 0.60 + 0.75) = 0.68

The source reports the overall F-score for this model as 0.71.

  • Use beta to emphasize precision or recall depending on the specific requirements of an application (the source notes that beta is often set to 1 but may be changed when more weight should be given to precision or recall).
  • Precision
  • Recall
  • Confusion matrix