F1 score and recall

this is not in the notebook but can you explain what is the purpose of f1 score and recall in the classification report.

Great question. The issue with using accuracy as the performance metric for classification problems is that when you are wrong, the accuracy score does not tell you HOW you go wrong - which may be more important. For instance, if you have an imbalanced dataset with 90% class A, 5% class B, and 5% class C → then if your model accurately predicts all instances of Class A (therefore getting at least 90% accuracy) but struggles to distinguish between class B and class C, the 90% accuracy may sound great but the fact remains that your model is terrible for distinguishing between class B and class C - and this is where the model needs to be improved. What you need is a class-by-class breakdown of how well you performed in terms of predicting (1) class A, (2) class B, and (3) class C.

Metrics like precision and recall give you a class-by-class breakdown of how well you did in terms of categorising each class. The F1-score is just the harmonic mean of precision and recall and tries to encapsulate info from both metrics by one number.

The precision is the percentage (or fraction) of YOUR predictions - broken down by class - that are correct.
The recall is the percentage (or fraction) of REAL outcomes - broken down by class - that you are able to predict correctly.

1 Like