F1 Score - Machine Learning Tutorials, Courses and Certifications

F1 Score - Machine Learning Tutorials, Courses and Certifications

Machine Learning October 3, 2024 Classification , Supervised Machine Learning Comments Off on F1 Score 2,483 Views

The F1 Score is a metric used to evaluate the performance of a classification model by combining both precision and recall into a single score. It provides a balance between precision and recall, especially when there is an uneven class distribution or when both false positives and false negatives are important to consider.

The formula for the F1 score is the harmonic mean of precision and recall:

$F1 = 2 \times \frac{\text{Precision} \times \text{Recall}}{\text{Precision} + \text{Recall}}$

If a model has a precision of 0.75 (75%) and a recall of 0.60 (60%), the F1 score would be calculated as:

$F1 = 2 \times \frac{0.75 \times 0.60}{0.75 + 0.60} = 2 \times \frac{0.45}{1.35} \approx 0.67$

A high F1 score means the model performs well in both precision and recall.

400 rows × 5 columns

The confusion matrix for sklearn is as follows:

Recommended articles