anomalib.utils.metrics.aupr

Implementation of AUROC metric based on TorchMetrics.

Module Contents

Classes

AUPR

Area under the PR curve.

class anomalib.utils.metrics.aupr.AUPR[source]

Bases: torchmetrics.PrecisionRecallCurve

Area under the PR curve.

compute() torch.Tensor[source]

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

Returns

Value of the AUPR metric

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

Update state with new values.

Need to flatten new values as PrecicionRecallCurve 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 prec/rec value pairs.

Returns

Tuple containing Tensors for rec and prec

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

Generate a figure containing the PR curve as well as the random baseline and the AUC.

Returns

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

Return type

Tuple[Figure, str]