# Multilabelauroc

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

- Skill: `qhjqhj00/multilabelauroc` (Agent Skill)
- Install (CLI): `npx skillmds add qhjqhj00/multilabelauroc`
- Raw SKILL.md: https://api.skillmd.com/api/skills/qhjqhj00/multilabelauroc/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/multilabelauroc

---


# multilabelauroc

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

## When to invoke this skill

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

## Reference signature

```python
from torchmetrics.classification import MultilabelAUROC

# MultilabelAUROC(num_labels: int, average: Optional[Literal['micro', '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 multilabel 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.

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 sigmoid per element.
- ``target`` (:class:`~torch.Tensor`): An int tensor of shape ``(N, C, ...)`` containing ground truth labels, and
  therefore only contain {0,1} values (except if `ignore_index` is specified).

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

- ``ml_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="micro|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_{labels})` (constant memory).

Args:
    num_labels: Integer specifying the number of labels
    average:
        Defines the reduction that is applied over labels. Should be one of the following:

        - ``micro``: Sum score over all labels
        - ``macro``: Calculate score for each label and average them
        - ``weighted``: calculates score for each label and computes weighted average using their support
        - ``"none"`` or ``None``: 
```

## Quick recipe

```python
import torchmetrics.classification as _m
score = _m.MultilabelAUROC(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)`.

