📏  Macro AUROC (Macro-Averaged AUROC)

Macro AUROC (Macro-Averaged AUROC)#

The mean of per-class AUROC values, weighting every class equally regardless of size.

Important

✨ AI-generated content. This page was written with the assistance of an AI language model and is provided as a learning aid. Despite careful review, it may still contain mistakes, omissions, or out-of-date information. Whether you are new to the topic, a team lead, or a senior practitioner, treat it as a starting point rather than an authoritative reference: read it critically and independently verify anything you act on (code, commands, figures, and factual claims) against official documentation and primary sources before relying on it.

What it is#

AUROC measures ranking ability for a binary task — the probability a random positive outscores a random negative, ranging from 0.5 (chance) to 1.0 (perfect). Since ROC is inherently binary, a \(K\)-class model is scored by reducing it with one-vs-rest (OvR) (or one-vs-one). Macro AUROC averages the per-class OvR AUROCs with equal weight:

\[\text{AUROC}_{\text{macro}} = \frac{1}{K} \sum_{i=1}^{K} \text{AUROC}(\text{class}_i \;\text{vs}\; \text{rest}).\]

Because every class counts the same, a rare class the model handles badly drags the score down just as much as a common one.

Macro vs micro#

Macro gives equal weight per class, so it is sensitive to minority-class performance. Micro pools all OvR decisions into one global AUROC and is therefore dominated by majority classes. They answer different questions — fairness across classes vs overall sample-level discrimination — so reporting both is good practice. The scale matches binary AUROC in every case.

Worked example#

Three classes with AUROC(A vs rest)=0.85, AUROC(B vs rest)=0.72, AUROC(C vs rest)=0.65:

\[\text{AUROC}_{\text{macro}} = \frac{0.85 + 0.72 + 0.65}{3} = 0.74.\]

If C is rare but poorly separated, macro AUROC reflects it; micro might not.

Pitfalls and edge cases#

  • Undefined per-class AUROC — if a class has no positive (or no negative) samples in the evaluation set, its OvR AUROC is undefined and breaks the average; guard against empty classes.

  • Equal weighting cuts both ways — a single tiny, hard class can dominate the headline number; inspect the per-class AUROCs, not just the mean.

  • Weighted variant — averaging the per-class AUROCs by class frequency gives a middle ground between macro and micro.

In code#

from sklearn.metrics import roc_auc_score

macro = roc_auc_score(y_true, y_score, multi_class="ovr", average="macro")
per_class = roc_auc_score(y_true, y_score, multi_class="ovr", average=None)

Theme: Classification & Averaging Metrics  ·  All terminology


Hint

Mind map — connected ideas

Micro AUROC · One-vs-Rest (OvR) AUROC · Macro F1 · Macro Recall


See also

Source article Adapted (context, re-expressed) in our own words from: Macro AUROC (Macro-Averaged AUROC) (insightful-data-lab.com).

Tags: purpose: reference topic: terminology level: intermediate