What is F1-Score? Why Harmonic mean?

Thiruthuvaraj Rajasekhar
2 min readMar 8, 2022

As a Data Scientist, if we are solving classification problems, we would have definitely come across f1-score metric.

Through this article, I want to explain what does F1-Score mean from business stand and why should we even consider this metric?

In order to understand F1-Score metric, we should understand what precision and recall. There is a simple article where you can refer about this.

f1-score = (2 x precision x recall)/(precision + recall)

which is nothing but Harmonic mean of Precision and recall metrics.

Precision is a measure, that tells out of all true predictions of my model, how many are actually true.

Recall is a measure, that tells out of all true actual values, how many are actually true.

Suppose, precision is 0.7, that means my model prediction 100 instances as True class out of which 70 instances are actually True. And suppose recall is 0.5, that means out of 100 true instances in my data, my model is able to predict 50 as True.

Lets consider a situation where we have a dataset of 99 False, 1 True class

If my model predicts everything as True, then Precision is 1/(100) = 0.01
and Recall is 1/(1+0) = 1. Hence in this case, even though all my True classes are predicted correct, we are increasing the cases of Predicting Trues which might affect business. For example, In Recommending YouTube videos, we cannot recommend all videos to the User, that might involve in High expenditure for company and User might loose interest in using YouTube. So here Precision should be of high importance.

Hence we need a balance between Precision and Recall, F1-score comes to our rescue, which balances precision and recall.

Here comes, why we need to do Harmonic mean instead of Arithmetic mean.

If you use Arithmetic mean in the above example, we would end up with
(1+0.01)/2 = 0.505 which says ~50% of predictions are True. But in reality it is not. If we consider harmonic mean, then we would have a value
(2 x 0.01 x 1)/(1+0.01) ~ 0.019 which actually says that the model is far worse.

F1 in simple terms F1 is a measure that treats precision and recall are equally important.

Hope you liked my article!!!!

--

--

Thiruthuvaraj Rajasekhar

Mining Data For Insights | Passionate to write | Data Scientist