AUROC

Contents

AUROC#

class anomalib.metrics.AUROC(fields=None, prefix='', strict=True, **kwargs)#

Bases: AnomalibMetric, _AUROC

Wrapper to add AnomalibMetric functionality to AUROC metric.

This class wraps the internal _AUROC metric to make it compatible with Anomalib’s batch processing capabilities.

Example

>>> from anomalib.metrics import AUROC
>>> from anomalib.data import ImageBatch
>>> import torch
>>> # Create sample batch
>>> batch = ImageBatch(
...     image=torch.rand(4, 3, 32, 32),
...     pred_score=torch.tensor([0.1, 0.2, 0.8, 0.9]),
...     gt_label=torch.tensor([0, 0, 1, 1])
... )
>>> # Initialize and compute AUROC
>>> auroc = AUROC(fields=["pred_score", "gt_label"])
>>> auroc(batch)
tensor(1.0)