code: def plotly_cumulative_precision_plot(
      lift_curve_df, labels=None, percentile=None, round=2, pos_label=1
  ):
      """Return cumulative precision plot showing the expected label distribution
      if you cumulatively sample a more and more of the highest predicted samples.
  
      Args:
          lift_curve_df (pd.DataFrame): generated with get_liftcurve_df(...)
          labels (List[str], optional): list of labels for classes. Defaults to None.
          percentile (float, optional): draw line at percentile, defaults to None
          round (int, optional): round floats to digits. Defaults to 2.
          pos_label (int, optional): Positive class label. Defaults to 1.
  
      Returns:
          Plotly fig
      """
      if labels is None:
          labels = [
              "category " + str(i)
              for i in range(lift_curve_df.y.max() + 1)
          ]
      fig = go.Figure()
      text = [
          f"percentage sampled = top {idx_perc:.{round}f}%"
          for idx_perc in lift_curve_df["index_percentage"].values
      ]
      fig = fig.add_trace(
          go.Scatter(
              x=lift_curve_df.index_percentage,
              y=np.zeros(len(lift_curve_df)),
              showlegend=False,
              text=text,
              hoverinfo="text",
          )
      )
  
      text = [
          f"percentage {labels[pos_label]}={perc:.{round}f}%"
          for perc in lift_curve_df[
              "precision_" + str(pos_label)
          ].values
      ]
      fig = fig.add_trace(
          go.Scatter(
              x=lift_curve_df.index_percentage,
              y=lift_curve_df["precision_" + str(pos_label)].values,
              fill="tozeroy",
              name=labels[pos_label],
              text=text,
              hoverinfo="text",
          )
      )
  
      cumulative_y = lift_curve_df["precision_" + str(pos_label)].values
      for y_label in range(pos_label, lift_curve_df.y.max() + 1):
          if y_label != pos_label:
              cumulative_y = (
                  cumulative_y
                  + lift_curve_df["precision_" + str(y_label)].values
              )
              text = [
                  f"percentage {labels[y_label]}={perc:.{round}f}%"
                  for perc in lift_curve_df[
                      "precision_" + str(y_label)
                  ].values
              ]
              fig = fig.add_trace(
                  go.Scatter(
                      x=lift_curve_df.index_percentage,
                      y=cumulative_y,
                      fill="tonexty",
                      name=labels[y_label],
                      text=text,
                      hoverinfo="text",
                  )
              )
  
      for y_label in range(0, pos_label):
          if y_label != pos_label:
              cumulative_y = (
                  cumulative_y
                  + lift_curve_df["precision_" + str(y_label)].values
              )
              text = [
                  f"percentage {labels[y_label]}={perc:.{round}f}%"
                  for perc in lift_curve_df[
                      "precision_" + str(y_label)
                  ].values
              ]
              fig = fig.add_trace(
                  go.Scatter(
                      x=lift_curve_df.index_percentage,
                      y=cumulative_y,
                      fill="tonexty",
                      name=labels[y_label],
                      text=text,
                      hoverinfo="text",
                  )
              )
  
      fig.update_layout(
          title=dict(
              text="Cumulative percentage per category<br>when sampling top X%",
              x=0.5,
              font=dict(size=18),
          ),
          yaxis=dict(title="Cumulative precision per category"),
          xaxis=dict(
              title="Top X% model scores",
              spikemode="across",
              range=[0, 100],
          ),
          hovermode="x",
          plot_bgcolor="#fff",
      )
  
      if percentile is not None:
          fig.update_layout(
              shapes=[
                  dict(
                      type="line",
                      xref="x",
                      yref="y",
                      x0=100 * percentile,
                      x1=100 * percentile,
                      y0=0,
                      y1=100.0,
                  )
              ]
          )
          fig.update_layout(
              annotations=[
                  go.layout.Annotation(
                      x=100 * percentile,
                      y=20,
                      yref="y",
                      ax=60,
                      text=f"percentile={100*percentile:.{round}f}",
                  )
              ]
          )
      fig.update_xaxes(nticks=10)
      fig.update_layout(margin=dict(t=40, b=40, l=40, r=40))
      return fig
  
imports: import warnings
  import numpy
  import pandas
  from pandas.api.types import is_numeric_dtype
  import plotly.graph_objs
  from plotly.subplots import make_subplots
  from sklearn.metrics import classification_report, confusion_matrix, precision_recall_curve, roc_curve, roc_auc_score, average_precision_score
  from .explainer_methods import matching_cols, safe_isinstance
label_desc: Use image node_id 6 for calling a global function with example usage: plotly_cumulative_precision_plot(lift_curve_df, labels, percentile, round, pos_label) and returns: fig