Calculate your F1 score instantly using precision and recall or confusion matrix values. A simple tool for machine learning, classification, and model evaluation.
The F1 score is a crucial evaluation metric in machine learning classification that combines both precision and recall into a single harmonic mean. It is particularly useful when you need to balance these two metrics, especially in scenarios involving imbalanced datasets where a high accuracy might be misleading.
The F1 score can be calculated using either the base metrics (Precision and Recall) or directly from the confusion matrix values.
Using Confusion Matrix values (True Positive, False Positive, False Negative):
A higher F1 score indicates a stronger combination of precision and recall on your evaluation data. The score ranges from 0 to 1 (or 0% to 100%), where 1 represents perfect precision and recall. However, what constitutes a "good" F1 score heavily depends on the specific context of your problem, the baseline performance, and the cost of false positives versus false negatives in your domain.
Let's take a scenario where TP = 45, FP = 10, and FN = 5.
| Metric | Formula | Objective |
|---|---|---|
| Precision | TP / (TP + FP) | Measures quality. Out of all positive predictions, how many were actually positive? |
| Recall | TP / (TP + FN) | Measures quantity. Out of all actual positives, how many were found? |
| F1 Score | Harmonic Mean | Strikes a balance between Precision and Recall. |