class_docstr: Area under the PR curve.
class_docstr_tok: ["Area","under","the","PR","curve","."]
docstr: Generate a figure containing the PR curve as well as the random baseline and the AUC.
  
  Returns:
      tuple[Figure, str]: Tuple containing both the PR curve and the figure title to be used for logging
docstr_tok: ["Generate","a","figure","containing","the","PR","curve","as","well","as","the","random","baseline","and","the","AUC",".","Returns",":","tuple","[","Figure",",","str","]",":","Tuple","containing","both","the","PR","curve","and","the","figure","title","to","be","used","for","logging"]
code: def generate_figure(self) -> tuple[Figure, str]:
      """Generate a figure containing the PR curve as well as the random baseline and the AUC.
  
      Returns:
          tuple[Figure, str]: Tuple containing both the PR curve and the figure title to be used for logging
      """
      prec, rec = self._compute()
      aupr = self.compute()
  
      xlim = (0.0, 1.0)
      ylim = (0.0, 1.0)
      xlabel = "Precision"
      ylabel = "Recall"
      loc = "best"
      title = "AUPR"
  
      fig, axis = plot_figure(
          rec, prec, aupr, xlim, ylim, xlabel, ylabel, loc, title
      )
  
      # Baseline in PR-curve is the prevalence of the positive class
      rate = (dim_zero_cat(self.target) == 1).sum() / (
          dim_zero_cat(self.target).size(0)
      )
      axis.plot(
          (0, 1),
          (rate.detach().cpu(), rate.detach().cpu()),
          color="navy",
          lw=2,
          linestyle="--",
          figure=fig,
      )
  
      return fig, title
  
file_path: anomalib/src/anomalib/utils/metrics/aupr.py
imports: from __future__ import annotations
  from matplotlib.figure import Figure
  from torch import Tensor
  from torchmetrics import PrecisionRecallCurve
  from torchmetrics.functional import auc
  from torchmetrics.utilities.data import dim_zero_cat
  from .plotting_utils import plot_figure
label_desc: Use image node_id 4 for calling the AUPR obj's underlying member method code with example usage: obj.generate_figure() and returns: fig,  title