Micro AUC
Micro AUC flattens a multi-class or multilabel problem into one binary one and scores it once. Every sample contributes one row per class — “does this sample belong to class \(k\)?” — and the pooled labels and scores go into a single area calculation.
Which area is the question the name leaves open, and it is not a detail: the two candidates have different no-skill baselines, so the same pooled ranking produces two numbers that have to be read against different reference points.
import numpy as np
from sklearn.metrics import roc_auc_score, average_precision_score
rng = np.random.default_rng(6)
names = ["common", "medium", "rare"]
support = dict(zip(names, (4000, 800, 120)))
y = np.concatenate([[k] * n for k, n in enumerate(support.values())])
onehot = np.eye(len(names))[y]
scores = rng.normal(size=onehot.shape) + 1.2 * onehot
probs = np.exp(scores) / np.exp(scores).sum(axis=1, keepdims=True)
flat_y, flat_p = onehot.ravel(), probs.ravel()
print(f"pooled rows {flat_y.size} positives {int(flat_y.sum())} positive rate {flat_y.mean():.4f}")
print(f"micro ROC-AUC {roc_auc_score(flat_y, flat_p):.4f} chance 0.5000")
print(f"micro AP {average_precision_score(flat_y, flat_p):.4f} chance {flat_y.mean():.4f}")
per_roc = [roc_auc_score(onehot[:, k], probs[:, k]) for k in range(len(names))]
print(f"macro ROC-AUC {np.mean(per_roc):.4f}")
# pooled rows 14760 positives 4920 positive rate 0.3333
# micro ROC-AUC 0.8602 chance 0.5000
# micro AP 0.7648 chance 0.3333
# macro ROC-AUC 0.8601
The same predictions give ROC-AUC 0.8602 and average precision (AP) 0.7648. AP weights precision by recall increments; it differs from a PR area computed with linear interpolation. Their no-skill reference levels are 0.5 and, for this pooled single-label problem, 1/3 respectively.
Why the baseline is 1/K
That 0.3333 is worth pausing on. In a single-label problem every sample is positive for exactly one class and negative for the other \(K - 1\), so the pooled set always has a positive rate of \(1/K\) — here one third, on a dataset whose actual classes split 81, 16 and 2 percent.
The pooled prevalence is 1/K regardless of the original class imbalance. It is a no-skill reference for this precision–recall summary, not a lower bound: poor rankings can score below it. Report per-class AP and prevalence as well, since the pooled problem can conceal which classes are rare and poorly served; macro AUC compares those class-level summaries.
What “dominated by frequent classes” means
Micro averaging is described as weighting by class frequency, and the mechanism is narrower than that phrasing suggests. Each sample contributes exactly \(K\) rows, so samples carry equal weight. The imbalance is in the positives: the class holding 81 percent of the data supplies 81 percent of the positive rows, so its ranking behavior is most of what the number measures and a rare class barely registers.
In a multilabel problem each sample still contributes K binary entries when all labels are evaluated. Samples can contribute different numbers of positive entries, which changes how their labels enter the pooled positive–negative comparisons.
Reporting it
| State this | Because |
|---|---|
| Which curve | ROC-AUC and AP differ by about 0.10 above; specify the metric and integration convention |
| The baseline | 0.5 for ROC, \(1/K\) for micro PR in single-label problems |
| The macro figure too | Compare per-class results, supports and score scales; a macro–micro gap alone does not identify which class failed or why |
| Which scores were pooled | Pooling compares one class’s scores against another’s — see micro AUROC |
scikit-learn accepts average="micro" in average_precision_score, and supports multiclass micro ROC-AUC with multi_class="ovr". The multiclass ROC interface expects probability rows summing to one in the correct class order. Explicit flattening also computes the pooled binary metric and makes the pooling visible. Specify the construction used, especially when working with scores rather than probability vectors.
References
- scikit-learn API reference, average_precision_score
- scikit-learn API reference, roc_auc_score
- Takaya Saito and Marc Rehmsmeier, “The Precision-Recall Plot Is More Informative than the ROC Plot When Evaluating Binary Classifiers on Imbalanced Datasets”, PLOS ONE, 10(3), 2015
Discover more from Insightful Data Lab
Subscribe to get the latest posts sent to your email.
