anomalib.utils.metrics.auroc

Implementation of AUROC metric based on TorchMetrics.

Module Contents

Classes

AUROC

Area under the ROC curve.

class anomalib.utils.metrics.auroc.AUROC[source]

Bases: torchmetrics.ROC

Area under the ROC curve.

compute() torch.Tensor[source]

First compute ROC curve, then compute area under the curve.

Returns

Value of the AUROC metric

Return type

Tensor

update(preds: torch.Tensor, target: torch.Tensor) None[source]

Update state with new values.

Need to flatten new values as ROC expects them in this format for binary classification.

Parameters
  • preds (Tensor) – predictions of the model

  • target (Tensor) – ground truth targets

_compute() Tuple[torch.Tensor, torch.Tensor][source]

Compute fpr/tpr value pairs.

Returns

Tuple containing Tensors for fpr and tpr

generate_figure() Tuple[matplotlib.figure.Figure, str][source]

Generate a figure containing the ROC curve, the baseline and the AUROC.

Returns

Tuple containing both the figure and the figure title to be used for logging

Return type

Tuple[Figure, str]