code: def precision_recall(y_true, y_score, ax=None):
      """
      Plot precision-recall curve.
  
      Parameters
      ----------
      y_true : array-like, shape = [n_samples]
          Correct target values (ground truth).
      y_score : array-like, shape = [n_samples] or [n_samples, 2] for binary
                classification or [n_samples, n_classes] for multiclass
  
          Target scores (estimator predictions).
      ax : matplotlib Axes
          Axes object to draw the plot onto, otherwise uses current Axes
  
      Notes
      -----
      It is assumed that the y_score parameter columns are in order. For example,
      if ``y_true = [2, 2, 1, 0, 0, 1, 2]``, then the first column in y_score
      must contain the scores for class 0, second column for class 1 and so on.
  
  
      Returns
      -------
      ax: matplotlib Axes
          Axes containing the plot
  
      Examples
      --------
      .. plot:: ../examples/precision_recall.py
  
      """
      if any((val is None for val in (y_true, y_score))):
          raise ValueError(
              "y_true and y_score are needed to plot "
              "Precision-Recall"
          )
  
      if ax is None:
          ax = plt.gca()
  
      # get the number of classes from y_score
      y_score_is_vector = is_column_vector(y_score) or is_row_vector(
          y_score
      )
      if y_score_is_vector:
          n_classes = 2
      else:
          _, n_classes = y_score.shape
  
      # check data shape?
  
      if n_classes > 2:
          # convert y_true to binary format
          y_true_bin = label_binarize(y_true, classes=np.unique(y_true))
          _precision_recall_multi(y_true_bin, y_score, ax=ax)
          for i in range(n_classes):
              _precision_recall(y_true_bin[:, i], y_score[:, i], ax=ax)
      else:
          if y_score_is_vector:
              _precision_recall(y_true, y_score, ax)
          else:
              _precision_recall(y_true, y_score[:, 1], ax)
  
      # raise error if n_classes = 1?
      return ax
  
file_path: sklearn-evaluation/src/sklearn_evaluation/plot/precision_recall.py
imports: import numpy
  import matplotlib.pyplot
  from sklearn.metrics import precision_recall_curve, average_precision_score
  from sklearn.preprocessing import label_binarize
  from ..telemetry import SKLearnEvaluationLogger
  from ..util import is_column_vector, is_row_vector
  from ploomber_core.exceptions import modify_exceptions
label_desc: Use image node_id 1 for calling a global function with example usage: precision_recall(y_true, y_score, ax) and returns: ax