CalcWorldHub
Free online calculator · no signup

Micro and macro F1 score calculator

Compute micro-averaged and macro-averaged F1 from per-class true-positive, false-positive, and false-negative counts.

4,000 tools
Micro and macro F1 score calculator — True positives by class, False positives by class, False negatives by class and calculation method
Micro and macro F1 score calculator: inputs and calculation method.

How to use this calculator

Compute micro-averaged and macro-averaged F1 from per-class true-positive, false-positive, and false-negative counts.

  1. Enter True positives by class, False positives by class, False negatives by class. Match the units shown beside each field and review the result together with the assumptions below.
  2. Read the worked example below to check the expected input format and result.
  3. Compare another scenario by changing one input at a time. Use Reset to return to the starting values.
Data science calculation

How this calculation works

A single-class F1 does not summarize class imbalance the same way as a multiclass average. Micro F1 pools decisions; macro F1 weights each represented class equally.

Inputs and units

tp — True positives by class
Comma-separated nonnegative integer counts, one per class.
fp — False positives by class
List in the same class order as true positives.
fn — False negatives by class
List in the same class order as true positives.

Formula

Displayed formula

F1ᵢ = 2TPᵢ/(2TPᵢ+FPᵢ+FNᵢ); micro F1 = 2ΣTP/(2ΣTP+ΣFP+ΣFN); macro F1 = mean(F1ᵢ).

Worked example

For TP=(40,8,3), FP=(6,12,1), FN=(10,2,7), micro F1 = 102/(102+19+19)=0.7286. Class F1 values are 0.8333, 0.5333, and 0.4286, so macro F1 ≈ 0.5984.

Assumptions and limits

Enter aligned nonnegative integer count lists. Classes with no true or predicted instances are excluded from macro averaging; this is not a threshold-free metric.

Frequently asked questions

Why can micro and macro F1 differ?

Micro F1 pools all class decisions, while macro F1 gives each represented class equal weight.

Should absent classes count as zero?

This implementation excludes a class with no TP, FP, or FN; document that convention when reporting scores.

Can these counts be negative?

No. Confusion counts are nonnegative integers.

How do I use the Micro and macro F1 score calculator?

Enter True positives by class, False positives by class, False negatives by class. Match the units shown beside each field and review the result together with the assumptions below.

What is a worked example of Micro and macro F1 score?

For TP=(40,8,3), FP=(6,12,1), FN=(10,2,7), micro F1 = 102/(102+19+19)=0.7286. Class F1 values are 0.8333, 0.5333, and 0.4286, so macro F1 ≈ 0.5984.