code: def plot_precision_recall_curve(
      df,
      grouping_col=None,
      recall_col="recall",
      precision_col="precision",
      axis_font_size=18,
      title_font_size=20,
      title="Precision - Recall Curve",
      opacity=0.95,
  ):
      """Plots a Precision - Recall curve, where the x axis is recall and the y axis is precision.
      If ``grouping_col`` is None, it creates one Precision - Recall curve given the data in ``df``.
      Otherwise, this function creates an overlay plot for multiple Precision - Recall curves, one for each level in the ``grouping_col``.
  
      Parameters
      ----------
      df : `pandas.DataFrame`
          The input dataframe. Must contain the columns:
  
              - ``recall_col``: `float`
              - ``precision_col``: `float`
  
          If ``grouping_col`` is not None, it must also contain the column ``grouping_col``.
      grouping_col : `str` or None, default None
          Column name for the grouping column.
      recall_col : `str`, default "recall"
          Column name for recall.
      precision_col : `str`, default "precision"
          Column name for precision.
      axis_font_size : `int`, default 18
          Axis font size.
      title_font_size : 20
          Title font size.
      title : `str`, default "Precision - Recall Curve"
          Plot title.
      opacity : `float`, default 0.95
          The opacity of the color. This has to be a number between 0 and 1.
  
      Returns
      -------
          fig : `plotly.graph_objs._figure.Figure`
              Plot figure.
      """
      if any(
          [col not in df.columns for col in [recall_col, precision_col]]
      ):
          raise ValueError(
              f"`df` must contain the `recall_col`: '{recall_col}' and the `precision_col`: '{precision_col}' specified!"
          )
      # Stores the curves to be plotted.
      data = []
      # Creates the curve(s).
      if grouping_col is None:  # Creates one precision - recall curve.
          num_colors = 1
          df.sort_values(recall_col, inplace=True)
          line = go.Scatter(
              x=df[recall_col].tolist(), y=df[precision_col].tolist()
          )
          data.append(line)
      else:  # Creates precision - recall curve for every level in `grouping_col`.
          if grouping_col not in df.columns:
              raise ValueError(
                  f"`grouping_col` = '{grouping_col}' is not found in the columns of `df`!"
              )
          num_colors = 0
          for level, indices in df.groupby(grouping_col).groups.items():
              df_subset = (
                  df.loc[indices]
                  .reset_index(drop=True)
                  .sort_values(recall_col)
              )
              line = go.Scatter(
                  name=f"{level}",
                  x=df_subset[recall_col].tolist(),
                  y=df_subset[precision_col].tolist(),
              )
              data.append(line)
              num_colors += 1
      # Creates a list of colors for the curve(s).
      color_list = get_distinct_colors(
          num_colors=num_colors, opacity=opacity
      )
      if color_list is not None:
          if len(color_list) < len(data):
              raise ValueError(
                  "`color_list` must not be shorter than the number of traces in this figure!"
              )
          for i, v in enumerate(data):
              v.line.color = color_list[i]
      # Creates the layout.
      range_epsilon = (
          0.05  # Space at the beginning and end of the margins.
      )
      layout = go.Layout(
          xaxis=dict(
              title=recall_col.title(),
              titlefont=dict(size=axis_font_size),
              range=[
                  0 - range_epsilon,
                  1 + range_epsilon,
              ],  # Sets the range of xaxis.
              tickfont_size=axis_font_size,
              tickformat=".0%",
              hoverformat=",.1%",
          ),  # Keeps 1 decimal place.
          yaxis=dict(
              title=precision_col.title(),
              titlefont=dict(size=axis_font_size),
              range=[
                  0 - range_epsilon,
                  1 + range_epsilon,
              ],  # Sets the range of yaxis.
              tickfont_size=axis_font_size,
              tickformat=".0%",
              hoverformat=",.1%",
          ),  # Keeps 1 decimal place.
          title=title.title(),
          title_x=0.5,
          titlefont=dict(size=title_font_size),
          autosize=False,
          width=1000,
          height=800,
      )
      # Creates the figure.
      fig = go.Figure(data=data, layout=layout)
      fig.update_yaxes(
          constrain="domain",  # Compresses the yaxis by decreasing its "domain".
          automargin=True,
          rangemode="tozero",
      )
      fig.update_xaxes(
          constrain="domain",  # Compresses the xaxis by decreasing its "domain".
          automargin=True,
          rangemode="tozero",
      )
      fig.add_hline(y=0.0, line_width=1, line_color="gray")
      fig.add_vline(x=0.0, line_width=1, line_color="gray")
      return fig
  
file_path: greykite/greykite/common/viz/timeseries_annotate.py
imports: import pandas
  import plotly.graph_objects
  from greykite.common.constants import ACTUAL_COL
  from greykite.common.constants import ANOMALY_COL
  from greykite.common.constants import END_TIME_COL
  from greykite.common.constants import PREDICTED_ANOMALY_COL
  from greykite.common.constants import PREDICTED_COL
  from greykite.common.constants import START_TIME_COL
  from greykite.common.constants import TIME_COL
  from greykite.common.features.adjust_anomalous_data import label_anomalies_multi_metric
  from greykite.common.viz.colors_utils import get_distinct_colors
  from greykite.common.viz.timeseries_plotting import plot_forecast_vs_actual
label_desc: Use image node_id 7 for calling a global function with example usage: plot_precision_recall_curve(df, grouping_col, recall_col, precision_col, axis_font_size, title_font_size, title, opacity) and returns: fig