F1 Score

What is the F1 Score?

The F1 Score is a performance metric used to evaluate binary classification models. It is the harmonic mean of precision and recall, which are two measures of classification performance. The F1 Score ranges from 0 to 1, with 1 indicating perfect precision and recall and 0 indicating the worst possible performance. It is particularly useful for evaluating models on imbalanced datasets, as it takes into account both false positives and false negatives.

Example of calculating the F1 Score using scikit-learn in Python:

from sklearn.metrics import f1_score
y_true = [0, 1, 1, 0, 1, 1]
y_pred = [0, 1, 0, 0, 1, 1]
f1 = f1_score(y_true, y_pred)
print("F1 Score:", f1)

In this example, we use the scikit-learn library to calculate the F1 Score for a binary classification problem with sample ground-truth labels and predictions.

Resources

To learn more about the F1 Score and its applications in machine learning, you can explore the following resources: