# Multiclassauroc

> Compute the MulticlassAUROC metric — provided by torchmetrics. Use when the user has predictions and ground-truth and needs to compute MulticlassAUROC, or asks how to score with MulticlassAUROC.

- Skill: `qhjqhj00/multiclassauroc` (Agent Skill)
- Install (CLI): `npx skillmds add qhjqhj00/multiclassauroc`
- Raw SKILL.md: https://api.skillmd.com/api/skills/qhjqhj00/multiclassauroc/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: qhjqhj00 (https://skillmd.com/u/qhjqhj00)
- Updated: 2026-09-08
- Page: https://skillmd.com/skills/qhjqhj00/multiclassauroc

---


# multiclassauroc

> Metric `MulticlassAUROC` from `torchmetrics` (torchmetrics.classification.MulticlassAUROC)

## When to invoke this skill

The user has predictions + ground truth and asks to evaluate with MulticlassAUROC, or
mentions `torchmetrics.classification.MulticlassAUROC` directly, or wants the standard torchmetrics implementation.

## Reference signature

```python
from torchmetrics.classification import MulticlassAUROC

# MulticlassAUROC(num_classes: int, average: Optional[Literal['macro', 'weighted', 'none']] = 'macro', thresholds: Union[int, list[float], torch.Tensor, NoneType] = None, ignore_index: Optional[int] = None, validate_args: bool = True, **kwargs: Any) -> None
```

## Library docstring

```
Compute Area Under the Receiver Operating Characteristic Curve (`ROC AUC`_) for multiclass tasks.

The AUROC score summarizes the ROC curve into an single number that describes the performance of a model for
multiple thresholds at the same time. Notably, an AUROC score of 1 is a perfect score and an AUROC score of 0.5
corresponds to random guessing.

For multiclass the metric is calculated by iteratively treating each class as the positive class and all other
classes as the negative, which is referred to as the one-vs-rest approach. One-vs-one is currently not supported by
this metric. By default the reported metric is then the average over all classes, but this behavior can be changed
by setting the ``average`` argument.

As input to ``forward`` and ``update`` the metric accepts the following input:

- ``preds`` (:class:`~torch.Tensor`): A float tensor of shape ``(N, C, ...)`` containing probabilities or logits
  for each observation. If preds has values outside [0,1] range we consider the input to be logits and will auto
  apply softmax per sample.
- ``target`` (:class:`~torch.Tensor`): An int tensor of shape ``(N, ...)`` containing ground truth labels, and
  therefore only contain values in the [0, n_classes-1] range (except if `ignore_index` is specified).

As output to ``forward`` and ``compute`` the metric returns the following output:

- ``mc_auroc`` (:class:`~torch.Tensor`): If `average=None|"none"` then a 1d tensor of shape (n_classes, ) will
  be returned with auroc score per class. If `average="macro"|"weighted"` then a single scalar is returned.

Additional dimension ``...`` will be flattened into the batch dimension.

The implementation both supports calculating the metric in a non-binned but accurate version and a binned version
that is less accurate but more memory efficient. Setting the `thresholds` argument to `None` will activate the
non-binned  version that uses memory of size :math:`\mathcal{O}(n_{samples})` whereas setting the `thresholds`
argument to either an integer, list or a 1d tensor will use a binned version that uses memory of
size :math:`\mathcal{O}(n_{thresholds} \times n_{classes})` (constant memory).

Args:
    num_classes: Integ
```

## Quick recipe

```python
import torchmetrics.classification as _m
score = _m.MulticlassAUROC(y_true, y_pred)
```

## Don'ts

- Don't reimplement when the library version handles edge cases (NaN, ties, empty inputs) better than a hand-rolled formula.
- Always check the library version's argument order — sklearn is `(y_true, y_pred)` while torchmetrics is `(preds, target)`.

