:py:mod:`anomalib.utils.metrics.adaptive_threshold` =================================================== .. py:module:: anomalib.utils.metrics.adaptive_threshold .. autoapi-nested-parse:: Implementation of Optimal F1 score based on TorchMetrics. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: anomalib.utils.metrics.adaptive_threshold.AdaptiveThreshold .. py:class:: AdaptiveThreshold(default_value: float = 0.5, **kwargs) Bases: :py:obj:`torchmetrics.Metric` Optimal F1 Metric. Compute the optimal F1 score at the adaptive threshold, based on the F1 metric of the true labels and the predicted anomaly scores. .. py:method:: update(preds: torch.Tensor, target: torch.Tensor) -> None Update the precision-recall curve metric. .. py:method:: compute() -> torch.Tensor Compute the threshold that yields the optimal F1 score. Compute the F1 scores while varying the threshold. Store the optimal threshold as attribute and return the maximum value of the F1 score. :returns: Value of the F1 score at the optimal threshold.