code: def precision_recall_curve(
      estimator,
      X_train,
      y_train,
      X_test=None,
      y_test=None,
      ax=None,
      classes=None,
      colors=None,
      cmap=None,
      encoder=None,
      fill_area=True,
      ap_score=True,
      micro=True,
      iso_f1_curves=False,
      iso_f1_values=DEFAULT_ISO_F1_VALUES,
      per_class=False,
      fill_opacity=0.2,
      line_opacity=0.8,
      is_fitted="auto",
      force_model=False,
      show=True,
      **kwargs,
  ):
      """Precision-Recall Curve
  
      Precision-Recall curves are a metric used to evaluate a classifier's quality,
      particularly when classes are very imbalanced. The precision-recall curve
      shows the tradeoff between precision, a measure of result relevancy, and
      recall, a measure of completeness. For each class, precision is defined as
      the ratio of true positives to the sum of true and false positives, and
      recall is the ratio of true positives to the sum of true positives and false
      negatives.
  
      A large area under the curve represents both high recall and precision, the
      best case scenario for a classifier, showing a model that returns accurate
      results for the majority of classes it selects.
  
      Parameters
      ----------
      estimator : estimator
          A scikit-learn estimator that should be a classifier. If the model is
          not a classifier, an exception is raised. If the internal model is not
          fitted, it is fit when the visualizer is fitted, unless otherwise specified
          by ``is_fitted``.
  
      X_train : ndarray or DataFrame of shape n x m
          A feature array of n instances with m features the model is trained on.
          Used to fit the visualizer and also to score the visualizer if test splits are
          not directly specified.
  
      y_train : ndarray or Series of length n
          An array or series of target or class values. Used to fit the visualizer and
          also to score the visualizer if test splits are not specified.
  
      X_test : ndarray or DataFrame of shape n x m, default: None
          An optional feature array of n instances with m features that the model
          is scored on if specified, using X_train as the training data.
  
      y_test : ndarray or Series of length n, default: None
          An optional array or series of target or class values that serve as actual
          labels for X_test for scoring purposes.
  
      ax : matplotlib Axes, default: None
          The axes to plot the figure on. If not specified the current axes will be
          used (or generated if required).
  
      classes : list of str, default: None
          The class labels to use for the legend ordered by the index of the sorted
          classes discovered in the ``fit()`` method. Specifying classes in this
          manner is used to change the class names to a more specific format or
          to label encoded integer classes. Some visualizers may also use this
          field to filter the visualization for specific classes. For more advanced
          usage specify an encoder rather than class labels.
  
      colors : list of strings,  default: None
          An optional list or tuple of colors to colorize the curves when
          ``per_class=True``. If ``per_class=False``, this parameter will
          be ignored. If both ``colors`` and ``cmap`` are provided,
          ``cmap`` will be ignored.
  
      cmap : string or Matplotlib colormap, default: None
          An optional string or Matplotlib colormap to colorize the curves
          when ``per_class=True``. If ``per_class=False``, this parameter
          will be ignored. If both ``colors`` and ``cmap`` are provided,
          ``cmap`` will be ignored.
  
      encoder : dict or LabelEncoder, default: None
          A mapping of classes to human readable labels. Often there is a mismatch
          between desired class labels and those contained in the target variable
          passed to ``fit()`` or ``score()``. The encoder disambiguates this mismatch
          ensuring that classes are labeled correctly in the visualization.
  
      fill_area : bool, default: True
          Fill the area under the curve (or curves) with the curve color.
  
      ap_score : bool, default: True
          Annotate the graph with the average precision score, a summary of the
          plot that is computed as the weighted mean of precisions at each
          threshold, with the increase in recall from the previous threshold used
          as the weight.
  
      micro : bool, default: True
          If multi-class classification, draw the precision-recall curve for the
          micro-average of all classes. In the multi-class case, either micro or
          per-class must be set to True. Ignored in the binary case.
  
      iso_f1_curves : bool, default: False
          Draw ISO F1-Curves on the plot to show how close the precision-recall
          curves are to different F1 scores.
  
      iso_f1_values : tuple , default: (0.2, 0.4, 0.6, 0.8)
          Values of f1 score for which to draw ISO F1-Curves
  
      per_class : bool, default: False
          If multi-class classification, draw the precision-recall curve for
          each class using a OneVsRestClassifier to compute the recall on a
          per-class basis. In the multi-class case, either micro or per-class
          must be set to True. Ignored in the binary case.
  
      fill_opacity : float, default: 0.2
          Specify the alpha or opacity of the fill area (0 being transparent,
          and 1.0 being completly opaque).
  
      line_opacity : float, default: 0.8
          Specify the alpha or opacity of the lines (0 being transparent, and
          1.0 being completly opaque).
  
      is_fitted : bool or str, default="auto"
          Specify if the wrapped estimator is already fitted. If False, the estimator
          will be fit when the visualizer is fit, otherwise, the estimator will not be
          modified. If "auto" (default), a helper method will check if the estimator
          is fitted before fitting it again.
  
      force_model : bool, default: False
          Do not check to ensure that the underlying estimator is a classifier. This
          will prevent an exception when the visualizer is initialized but may result
          in unexpected or unintended behavior.
  
      show: bool, default: True
          If True, calls ``show()``, which in turn calls ``plt.show()`` however you cannot
          call ``plt.savefig`` from this signature, nor ``clear_figure``. If False, simply
          calls ``finalize()``
  
      kwargs : dict
          Keyword arguments passed to the visualizer base classes.
  
      Returns
      -------
      viz : PrecisionRecallCurve
          Returns the visualizer that generates the curve visualization.
      """
      # Instantiate the visualizer
      viz = PRCurve(
          estimator,
          ax=ax,
          classes=classes,
          colors=colors,
          cmap=cmap,
          encoder=encoder,
          fill_area=fill_area,
          ap_score=ap_score,
          micro=micro,
          iso_f1_curves=iso_f1_curves,
          iso_f1_values=iso_f1_values,
          per_class=per_class,
          fill_opacity=fill_opacity,
          line_opacity=line_opacity,
          is_fitted=is_fitted,
          force_model=force_model,
          **kwargs,
      )
  
      # Fit the visualizer
      viz.fit(X_train, y_train)
  
      # Score the visualizer
      if X_test is not None and y_test is not None:
          viz.score(X_test, y_test)
      elif X_test is not None or y_test is not None:
          raise YellowbrickValueError(
              "both X_test and y_test are required if one is specified"
          )
      else:
          viz.score(X_train, y_train)
  
      # Draw the final visualization
      if show:
          viz.show()
      else:
          viz.finalize()
  
      # Return the visualizer
      return viz
  
imports: import warnings
  import numpy
  from sklearn.preprocessing import label_binarize
  from sklearn.multiclass import OneVsRestClassifier
  from sklearn.utils.multiclass import type_of_target
  from sklearn.metrics import average_precision_score
  from sklearn.metrics import precision_recall_curve
  from yellowbrick.style.colors import resolve_colors
  from yellowbrick.exceptions import YellowbrickWarning
  from yellowbrick.exceptions import ModelError, NotFitted
  from yellowbrick.exceptions import YellowbrickValueError
  from yellowbrick.classifier.base import ClassificationScoreVisualizer
label_desc: Use image node_id 1 for calling a global function with example usage: precision_recall_curve(estimator, X_train, y_train, X_test, y_test, ax, classes, colors, cmap, encoder, fill_area, ap_score, micro, iso_f1_curves, iso_f1_values, per_class, fill_opacity, line_opacity, is_fitted, force_model, show) and returns: viz