Evaluation12 of 21· 5 min read

Precision, Recall, and F1 — Explained Simply

What Precision, Recall, and F1 Actually Are

You Are a Doctor Screening Patients for a Disease

Four things can happen when you test a patient:

Patient HAS disease,  test says YES → Correct ✅  True Positive  (TP)
Patient HAS disease,  test says NO  → Wrong   ❌  False Negative (FN)
Patient NO disease,   test says YES → Wrong   ❌  False Positive (FP)
Patient NO disease,   test says NO  → Correct ✅  True Negative  (TN)

Every evaluation metric is built from combinations of these four numbers.

Why Accuracy Is Not Enough

Disease affects 1 in 100 people. A model that says NO to everyone:

Accuracy = 99%   ← looks amazing
But it never correctly identifies a single sick person.
Every sick person walks away thinking they are healthy.

A 99% accurate model that is completely useless. You need better metrics.

Precision — When You Flag Someone, How Often Are You Right?

You flagged 100 people as sick.
70 actually had the disease.
30 were healthy — false alarms.

Precision = TP / (TP + FP) = 70 / 100 = 0.70

High precision → when you raise the alarm, it is almost always real
Low precision  → too many false alarms

Recall — Of All the Sick People, How Many Did You Find?

200 people actually had the disease.
You correctly identified 140 of them.
60 sick people were told they were healthy.

Recall = TP / (TP + FN) = 140 / 200 = 0.70

High recall → you catch almost all sick people
Low recall  → many sick people slip through undetected

The Tension Between Them

Conservative doctor (high precision, low recall):
  Precision = 0.95 → Almost never wrong when flagging
  Recall    = 0.40 → But misses 60% of sick patients

Aggressive doctor (low precision, high recall):
  Precision = 0.45 → Many false alarms
  Recall    = 0.95 → But catches 95% of sick patients

Which is better depends on the cost of each mistake:

Disease detection:  False negatives far more costly → want high recall
Spam detection:     False positives more costly     → want high precision

F1 Score — The Balanced Measure

F1 = 2 × (Precision × Recall) / (Precision + Recall)

Both high:    P=0.70, R=0.70 → F1 = 0.70  ✅
One sacrificed: P=0.95, R=0.10 → F1 = 0.18  ← low despite high precision

F1 cannot be fooled — both must be high for F1 to be high

In Code

from sklearn.metrics import classification_report, f1_score

y_true = [0, 1, 2, 0, 1, 1, 2, 0, 1, 2]   # 0=Positive 1=Negative 2=Neutral
y_pred = [0, 1, 1, 0, 0, 1, 2, 1, 1, 2]

# Full report — goes in your research paper
print(classification_report(
    y_true, y_pred,
    target_names=['Positive', 'Negative', 'Neutral']
))

Output:

              precision    recall  f1-score   support

    Positive       0.67      0.67      0.67         3
    Negative       0.75      0.75      0.75         4
     Neutral       1.00      0.67      0.80         3

    accuracy                           0.70        10
   macro avg       0.81      0.70      0.74        10
weighted avg       0.79      0.70      0.73        10

The Three Averages

Macro average:    All classes weighted equally
Weighted average: Classes weighted by sample count ← use this ✅
Micro average:    Pool all predictions together

# For imbalanced Nigerian Pidgin data — weighted F1 is most honest
f1 = f1_score(y_true, y_pred, average='weighted')

The Confusion Matrix

from sklearn.metrics import confusion_matrix

cm = confusion_matrix(y_true, y_pred)
print(cm)

#              Predicted
#              Pos  Neg  Neu
# Actual Pos  [ 2    1    0 ]
# Actual Neg  [ 0    3    1 ]
# Actual Neu  [ 0    1    2 ]

# Diagonal = correct predictions
# Off-diagonal = mistakes
# Include as a figure in your research paper

What to Report in Your Research Paper

1. Weighted F1 score — primary metric
   "Our model achieves a weighted F1 of 0.83 on the NaijaFeel test set"

2. Per-class precision, recall, F1 — the full classification_report table

3. Confusion matrix — as a figure showing which classes get confused

4. Accuracy — secondary metric only

AfricaNLP and ACL reviewers specifically look for F1 scores
not just accuracy — reporting F1 shows you understand evaluation properly

The Real Words Mapped to the Story

In the StoryReal Technical Term
Patient sick, test says yesTrue Positive (TP)
Patient sick, test says noFalse Negative (FN)
Patient healthy, test says yesFalse Positive (FP)
Patient healthy, test says noTrue Negative (TN)
How trustworthy your flags arePrecision
How many real cases you caughtRecall
Missing a sick personFalse Negative
Falsely flagging healthy personFalse Positive
Balanced measure of bothF1 Score
Always saying no, 99% accurateAccuracy trap / class imbalance

The One Thing to Remember

Accuracy lies when classes are imbalanced. Precision tells you how trustworthy your positive predictions are. Recall tells you how many real positives you found. F1 balances both. Always report weighted F1 in your Nigerian Pidgin paper — it is the metric AfricaNLP and ACL reviewers will judge your model on.

← All Articles