Precision, Recall, and F1
Trade-offs you must understand.
Precision, Recall, and F1 is a free NLP Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the NLP Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Beyond One Number
To see past accuracy you split results into four buckets per class. From them come precision, recall, and F1, the metrics that matter.
The Positive Class
Pick the class you care about as positive, like spam or fraud. Precision and recall both describe how well you handle that class.
Precision: Trust the Alarms
Precision asks: of everything you flagged as positive, how many truly were? High precision means few false alarms.
Recall: Catch Them All
Recall asks: of all the real positives, how many did you catch? High recall means few misses slip through.
The Tug of War
Precision and recall usually trade off. Flag more items and recall rises but precision drops; flag fewer and the reverse happens.
Which One First?
Spam filters favor precision, since wrongly trashing real mail is costly. Cancer screens favor recall, since a missed case is far worse.
F1: One Balanced Score
The F1 score blends precision and recall into one number using their harmonic mean, rewarding models that do both well.
Why Harmonic Mean
F1 uses the harmonic mean so a model cannot fake it. If either precision or recall is near zero, F1 stays low too.
See Them in Python
scikit-learn prints all three at once with a tidy classification report you can scan per class.
from sklearn.metrics import classification_report
print(classification_report(y_true, y_pred))Get One Metric Alone
You can also pull a single metric directly when you only need F1 for the positive class.
from sklearn.metrics import f1_score
f1 = f1_score(y_true, y_pred)Pick by the Cost
No metric is best everywhere. Choose precision, recall, or F1 by the real-world cost of each mistake in your problem.
Quick Check
Match the metric to the question it answers.
Recap
Precision limits false alarms, recall limits misses, and F1 balances both. Let the cost of each error pick your metric. 📊
Frequently asked questions
Is the “Precision, Recall, and F1” lesson free?
Yes — the full text of “Precision, Recall, and F1” is free to read here on the web, and the NLP Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the NLP Academy course, upgrade to CoddyKit PRO.
What will I learn in “Precision, Recall, and F1”?
Trade-offs you must understand. You practise NLP Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start NLP Academy?
No prior experience is required. NLP Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Precision, Recall, and F1” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this NLP Academy lesson?
Yes. Every NLP Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Why Accuracy Can Lie
- Precision, Recall, and F1
- Reading the Confusion Matrix
- Cross-Validation Done Right