Precision / Recall / F1
Per-class and macro/weighted F1 from predictions.
About this tool
Paste the true and predicted labels and get precision, recall and F1 for each class, along with macro, micro and weighted F1 and accuracy. It works for two classes or many.
How to use
How it works
Per class: precision = TP / (TP + FP), recall = TP / (TP + FN), F1 = 2PR / (P + R). Macro F1 averages the classes equally, weighted F1 weights each class by its support, and micro F1 pools all predictions (equal to accuracy for single-label classification). The headline answer is macro F1.
P = TP/(TP+FP) R = TP/(TP+FN) F1 = 2PR/(P+R)
Worked example
Cats and dogs
- Input
- y_true: cat, cat, dog, dog, dog y_pred: cat, dog, dog, dog, cat
- Output
- Macro F1 0.583333; micro 0.6; weighted 0.6 cat P/R/F1 0.5 / 0.5 / 0.5 (n=2) dog P/R/F1 0.666667 / 0.666667 / 0.666667 (n=3)
- Walkthrough
- For cat, 1 of 2 predicted cats was right (P = 0.5) and 1 of 2 true cats was found (R = 0.5). Macro F1 = (0.5 + 0.6667) / 2 = 0.5833.
Limitations
- Binary data (1 and 0) shows both classes; read the row for your positive class.
- No choice of positive label or zero-division handling options.
- Labels are exact text matches.
Questions
How do I calculate F1 score?
Macro vs micro vs weighted F1?
What is the difference between precision and recall?
Does it handle more than two classes?
Features
- Per-class P/R/F1
- Macro, micro, weighted
- Runs in your browser
Related resources
Guides and videos from around the web—opens on YouTube or the publisher’s site.
Big-O Notation in 100 Seconds
Fireship
Complexity intuition when estimating training/inference cost.
Watch on YouTubeFinding mean, median, and mode
Khan Academy
Baseline stats for accuracy and evaluation helpers.
Watch on YouTube
- Machine Learning Crash Course
Google Developers
Official ML crash course pairing with metric calculators.
- Metrics and scoring
scikit-learn
Precision, recall, F1 definitions used by AI metric tools.