Micro Precision
Micro precision pools the counts across all classes and divides once:
\(\text{Precision}_{\text{micro}} = \dfrac{\sum_{i=1}^{K} TP_i}{\sum_{i=1}^{K}(TP_i + FP_i)}\)
scikit-learn describes this as calculating the metric “globally by counting the total true positives, false negatives and false positives”, in contrast to macro, which averages the per-class values. Because a large class contributes more counts, micro follows the common classes and can look healthy while a rare class is ignored entirely.
It is accuracy
In a single-label problem — every sample gets exactly one predicted class — micro precision, micro recall, micro F1 and accuracy are the same number, provided the average is taken over every class. Restrict labels to a subset and the identity breaks: with truth [0, 1, 2], predictions [0, 0, 2] and labels=[0], micro precision is 0.5, micro recall is 1.0 and accuracy is 2/3.
import numpy as np
from sklearn.metrics import precision_score, recall_score, f1_score, accuracy_score
rng = np.random.default_rng(6)
names = ["common", "medium", "rare"]
support = dict(zip(names, (4000, 800, 120)))
hit_rate = dict(zip(names, (0.95, 0.70, 0.35)))
truth, pred = [], []
for name, n in support.items():
truth += [name] * n
others = [k for k in names if k != name]
pred += [name if rng.uniform() < hit_rate[name] else rng.choice(others) for _ in range(n)]
kw = dict(labels=names, average="micro", zero_division=0)
print(f"micro precision {precision_score(truth, pred, **kw):.6f}")
print(f"micro recall {recall_score(truth, pred, **kw):.6f}")
print(f"micro F1 {f1_score(truth, pred, **kw):.6f}")
print(f"accuracy {accuracy_score(truth, pred):.6f}")
multilabel_true = np.array([[1, 1, 0], [0, 1, 0], [1, 0, 1]])
multilabel_pred = np.array([[1, 0, 0], [0, 1, 1], [1, 1, 1]])
ml = dict(average="micro", zero_division=0)
print(f"multilabel: micro precision {precision_score(multilabel_true, multilabel_pred, **ml):.4f} "
f"micro recall {recall_score(multilabel_true, multilabel_pred, **ml):.4f}")
# micro precision 0.898171
# micro recall 0.898171
# micro F1 0.898171
# accuracy 0.898171
# multilabel: micro precision 0.6667 micro recall 0.8000
All four agree to six decimal places at 0.898171, which is not an approximation. Every misclassified sample is counted once as a false positive for the class it was wrongly assigned to and once as a false negative for the class it actually belonged to, so \(\sum FP = \sum FN\) exactly. The two denominators are therefore equal, the two micro values coincide, their harmonic mean is that same value, and \(\sum TP\) over the total is the definition of accuracy.
The practical consequence is blunt: if you are already reporting accuracy, micro precision adds no information. Reporting both as if they were two views of the model overstates how much has been measured.
Where the identity stops holding
The last line of the output is a multilabel case, where a sample can carry several labels at once. Micro precision is 0.6667 and micro recall is 0.8000 — different numbers, because predicting too few labels on one sample and too many on another no longer balances \(\sum FP\) against \(\sum FN\).
This is where micro averaging earns its place. On a multilabel problem it is a genuine summary rather than accuracy under another name, and it answers a question that per-sample accuracy — which usually requires every label on a sample to be right — answers far too harshly.
Choosing between them
| Situation | Report |
|---|---|
| Single-label multiclass, classes roughly equal in importance | Accuracy. Micro is the same number with a longer name |
| Single-label multiclass, rare classes matter | Macro precision and macro recall, with the per-class table |
| Multilabel | Micro precision and micro recall, which now differ and say different things |
| Comparing systems across datasets | State the scheme. Micro on a dataset with a different class mix is not comparable to micro on yours |
One consistency check worth running on any worked example: in a single-label problem scored over the full label set, the false positives and false negatives must sum to the same total. An example where they do not is describing two different confusion matrices, and any claim about micro precision equaling micro recall will not survive it.
References
Discover more from Insightful Data Lab
Subscribe to get the latest posts sent to your email.
