1

I need to prove mathematically that the value of Recall is always bigger or equal to the F1-score.

The equation would be: $2 \times Precision \times \frac{Recall}{(Precision + Recall)} \le Recall$

Does someone have an idea how I can prove this mathematically?

Alexis
  • 29,850
Agi
  • 13
  • 1
    The F1-score is the harmonic mean of precision and recall and so falls between them when they are different. So the statement you want to prove can only be true when recall is greater than or equal to precision. – Henry Dec 07 '22 at 12:45
  • @Henry thank you very much. This explanation makes it really clear, – Agi Dec 07 '22 at 13:20

3 Answers3

4

It isn't in general. R code:

> precision <- 0.9
> recall <- 0.5
> 2*precision*recall/(precision+recall)
[1] 0.6428571

A possible confusion matrix giving rise to these precision and recall values would be:

          Predicted P   Predicted N
Actual P       9             9
Actual N       1             5

Note that recall and precision suffer from precisely the same problems as accuracy.

Stephan Kolassa
  • 123,354
0

$$ \begin{array}{rl}\begin{array}{c}\\\\ \rlap{\vphantom{\frac{\frac{1}{1}}{\frac{1}{1}}}\require{HTML}\style{display: inline-block; transform: rotate(270deg)}{\text{truth}}}\end{array}&& \begin{array}{c|cc} & \rlap{\text{predictions}} \\ & P & N\\ \hline P & TP & FN \\ N & FP & TP\\ \end{array}\end{array}$$

You have

$$\begin{array}{rcl} \text{precision} &=& \frac{TP}{TP+FP} \\ \text{recall} &=& \frac{TP}{TP+FN} \end{array}$$

Recall and precision are related with both having $TP$ in the numerator.

In terms of $TP$, $FP$ and $FN$ you get for the $F$ score.

$$\begin{array}{}F& =& 2\frac{\frac{TP}{TP+FP} \cdot \frac{TP}{TP+FN}}{ \frac{TP}{TP+FP} + \frac{TP}{TP+FN} } \\ & =& \frac{ TP}{TP+FN} \cdot \underbrace{\frac{2(TP+FN)}{2(TP+FN)+FP-FN}}_{\text{$< 1$ if $FP>FN$} } \end{array}$$

So it is only true if $FP>FN$ or when recall is larger than precision. This makes sense since the F score is the averag of recall and precision. If precision is smaller than recall then the average will be smaller than recall.

-2

You can prove this mathematically by using the definition of precision and recall and the equation for the F1-score. Here is a proof:

First, let's define precision and recall:

Precision is the number of true positives divided by the total number of predicted positives. Recall is the number of true positives divided by the total number of actual positives. Now let's write the equation for the F1-score:

F1 = 2 * Precision * Recall / (Precision + Recall)

To prove that the recall value is always greater than or equal to the F1-score, we need to show that the numerator of the F1-score equation is always less than or equal to the denominator. In other words, we need to show that:

2 * Precision * Recall <= Precision + Recall

To do this, we can first multiply both sides of the equation by Precision + Recall, giving us:

2 * Precision * Recall * (Precision + Recall) <= (Precision + Recall)^2

Next, we can expand the right-hand side of the equation using the formula for the square of a sum:

(Precision + Recall)^2 = Precision^2 + 2 * Precision * Recall + Recall^2

Substituting this into the previous equation, we get:

2 * Precision * Recall * (Precision + Recall) <= Precision^2 + 2 * Precision * Recall + Recall^2

Now, we can move all the terms with Precision and Recall to the left-hand side of the equation, and all the constant terms to the right-hand side, giving us:

2 * Precision * Recall * (Precision + Recall) - Precision^2 - 2 * Precision * Recall - Recall^2 <= 0

Next, we can simplify the left-hand side of the equation by combining like terms and factoring out Precision and Recall:

(2 * Precision * Recall - Precision^2 - Recall^2) * (Precision + Recall) <= 0

Finally, we can apply the difference of squares factorization to the left-hand side of the equation:

(Precision + Recall) * (Precision - Recall) * (Precision + Recall) <= 0

Since the product of three numbers is always less than or equal to zero if one of the numbers is less than or equal to zero, we can see that the left-hand side of the equation is always less than or equal to zero. Therefore, the original equation is always true, which means that the recall value is always greater than or equal to the F1-score.

This completes the proof.

  • 2
    If you prove that the numerator of a fraction is always less than or equal to the denominator, then you have shown that the fraction is no larger than one, not that it is less than some specific number (like recall in this case). – Stephan Kolassa Dec 07 '22 at 11:54