Precision / Recall / F1

Per-class and macro/weighted F1 from predictions.

FreeNo accountOn your device

Runs in your browser. How to verify

Loading tool…

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

1
Step 1
Paste y_true, one label per line.
2
Step 2
Paste y_pred in the same order.
3
Step 3
Press Calculate and read the per-class rows.

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?
Paste true and predicted labels. F1 is shown per class and as macro, micro and weighted averages.
Macro vs micro vs weighted F1?
Macro treats classes equally, weighted accounts for class size, and micro pools all predictions.
What is the difference between precision and recall?
Precision asks how many predicted positives were right; recall asks how many real positives were found.
Does it handle more than two classes?
Yes. It supports multi-class data, not just binary classification.

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 YouTube
  • Finding mean, median, and mode

    Khan Academy

    Baseline stats for accuracy and evaluation helpers.

    Watch on YouTube