class_docstr: Produces precision-recall curves.
class_docstr_tok: ["Produces","precision-recall","curves","."]
docstr: Produce precision-recall curves.
  
  Args:
      X: Numpy array for X to compare predict function against.
      y: Numpy vector for y to compare predict function against.
      name: User-defined explanation name.
  
  Returns:
      An explanation object.
docstr_tok: ["Produce","precision-recall","curves",".","Args",":","X",":","Numpy","array","for","X","to","compare","predict","function","against",".","y",":","Numpy","vector","for","y","to","compare","predict","function","against",".","name",":","User-defined","explanation","name",".","Returns",":","An","explanation","object","."]
code: def explain_perf(self, X, y, name=None):
      """Produce precision-recall curves.
  
      Args:
          X: Numpy array for X to compare predict function against.
          y: Numpy vector for y to compare predict function against.
          name: User-defined explanation name.
  
      Returns:
          An explanation object.
      """
      if name is None:
          name = gen_name_from_class(self)
  
      y = clean_dimensions(y, "y")
      if y.ndim != 1:
          raise ValueError("y must be 1 dimensional")
  
      X, n_samples = preclean_X(
          X, self.feature_names, self.feature_types, len(y)
      )
  
      predict_fn, n_classes, classes = determine_classes(
          self.model, X, n_samples
      )
      if n_classes != 2:
          raise Exception(
              "Only binary classification supported in the PR class"
          )
      predict_fn = unify_predict_fn(predict_fn, X, 1)
  
      X, feature_names, feature_types = unify_data(
          X, n_samples, self.feature_names, self.feature_types, True, 0
      )
  
      y = typify_classification(y)
      if classes is None:
          # scikit-learn requires that the self.classes_ are sorted with np.unique, so rely on this
          classes, y = np.unique(y, return_inverse=True)
          if len(classes) != n_classes:
              raise ValueError("class number mismatch")
      else:
          invert_classes = dict(zip(classes, count()))
          y = np.array([invert_classes[el] for el in y], dtype=np.int64)
  
      scores = predict_fn(X)
  
      precision, recall, thresh = precision_recall_curve(y, scores)
      ap = average_precision_score(y, scores)
  
      abs_residuals = np.abs(y - scores)
      counts, values = np.histogram(abs_residuals, bins="doane")
  
      overall_dict = {
          "type": "perf_curve",
          "density": {"names": values, "scores": counts},
          "scores": scores,
          "x_values": recall,
          "y_values": precision,
          "threshold": thresh,
          "auc": ap,
      }
      internal_obj = {"overall": overall_dict, "specific": None}
  
      return PRExplanation(
          "perf",
          internal_obj,
          feature_names=feature_names,
          feature_types=feature_types,
          name=name,
      )
  
imports: from itertools import count
  from ..api.base import ExplainerMixin, ExplanationMixin
  from ..utils._explanation import gen_name_from_class
  from sklearn.metrics import roc_curve, auc
  from sklearn.metrics import precision_recall_curve, average_precision_score
  import numpy
  from ..utils._clean_x import preclean_X
  from ..utils._clean_simple import clean_dimensions, typify_classification
  from ..utils._unify_predict import determine_classes, unify_predict_fn
  from ..utils._unify_data import unify_data
label_desc: Use image node_id 2 for calling the PR obj's underlying member method code with example usage: obj.explain_perf(X, y, name) and returns: PRExplanation