Back to the lessonPreparing the printout…

Fundamental of Machine Learning · Module 3: Model Evaluation and Optimization

3.3 Precision, Recall, and F1 Score

[video] /api/lesson-media/videos/9b417aa2-5e9f-4ae3-a9db-2a3b7f03f372-1794891210516-1d4e10db351ccb78.mp4

[markdown] content available only on the platform

[markdown] content available only on the platform

Flashcards · 3.3 Precision, Recall, and F1 Score

Precision — TP / (TP + FP): of all samples predicted positive, the fraction that are truly positive.

3 / (3 + 1) = 0.75

Recall — TP / (TP + FN): of all truly positive samples, the fraction the model found.

3 / (3 + 2) = 0.6

F1 score — The harmonic mean of precision and recall: 2PR / (P + R).

2 * 0.75 * 0.6 / 1.35 = 0.67

Harmonic mean — An average that is pulled strongly towards the smaller value, so one low input makes the result low.

P = 1.0, R = 0 -> F1 = 0, not 0.5.

Precision-recall trade-off — Changes that raise precision often lower recall, and vice versa.

Flagging fewer emails as spam: fewer false alarms, more misses.

When to prioritise precision — When false positives are costly, such as blocking legitimate emails.

Spam filtering.

When to prioritise recall — When false negatives are costly, such as missing a sick patient.

Disease screening.

pos_label — Argument telling scikit-learn metric functions which label is the positive class.

precision_score(y, y_pred, pos_label='dog')

Fundamental of Machine Learning · 3.3 Precision, Recall, and F1 Score · printed on November 20, 2026