class_docstr: Class Prediction Error chart that shows the support for each class in the
  fitted classification model displayed as a stacked bar. Each bar is segmented
  to show the distribution of predicted classes for each class. It is initialized
  with a fitted model and generates a class prediction error chart on draw.
  
  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``.
  
  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, defult: 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.
  
  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.
  
  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.
  
  kwargs : dict
      Keyword arguments passed to the visualizer base classes.
  
  Attributes
  ----------
  classes_ : ndarray of shape (n_classes,)
      The class labels observed while fitting.
  
  class_count_ : ndarray of shape (n_classes,)
      Number of samples encountered for each class during fitting.
  
  score_ : float
      An evaluation metric of the classifier on test data produced when
      ``score()`` is called. This metric is between 0 and 1 -- higher scores are
      generally better. For classifiers, this score is usually accuracy, but
      ensure you check the underlying model for more details about the score.
  
  predictions_ : ndarray
      An ndarray of predictions whose rows are the true classes and
      whose columns are the predicted classes
class_docstr_tok: ["Class","Prediction","Error","chart","that","shows","the","support","for","each","class","in","the","fitted","classification","model","displayed","as","a","stacked","bar",".","Each","bar","is","segmented","to","show","the","distribution","of","predicted","classes","for","each","class",".","It","is","initialized","with","a","fitted","model","and","generates","a","class","prediction","error","chart","on","draw",".","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","``",".","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",",","defult",":","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",".","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",".","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",".","kwargs",":","dict","Keyword","arguments","passed","to","the","visualizer","base","classes",".","Attributes","--","--","--","--","--","classes_",":","ndarray","of","shape","(","n_classes",",",")","The","class","labels","observed","while","fitting",".","class_count_",":","ndarray","of","shape","(","n_classes",",",")","Number","of","samples","encountered","for","each","class","during","fitting",".","score_",":","float","An","evaluation","metric","of","the","classifier","on","test","data","produced","when","``","score","(",")","``","is","called",".","This","metric","is","between","0","and","1","--","higher","scores","are","generally","better",".","For","classifiers",",","this","score","is","usually","accuracy",",","but","ensure","you","check","the","underlying","model","for","more","details","about","the","score",".","predictions_",":","ndarray","An","ndarray","of","predictions","whose","rows","are","the","true","classes","and","whose","columns","are","the","predicted","classes"]
docstr: Generates a 2D array where each row is the count of the
  predicted classes and each column is the true class
  
  Parameters
  ----------
  X : ndarray or DataFrame of shape n x m
      A matrix of n instances with m features
  
  y : ndarray or Series of length n
      An array or series of target or class values
  
  Returns
  -------
  score_ : float
      Global accuracy score
docstr_tok: ["Generates","a","2D","array","where","each","row","is","the","count","of","the","predicted","classes","and","each","column","is","the","true","class","Parameters","--","--","--","--","--","X",":","ndarray","or","DataFrame","of","shape","n","x","m","A","matrix","of","n","instances","with","m","features","y",":","ndarray","or","Series","of","length","n","An","array","or","series","of","target","or","class","values","Returns","--","--","--","-","score_",":","float","Global","accuracy","score"]
code: def score(self, X, y):
      """
      Generates a 2D array where each row is the count of the
      predicted classes and each column is the true class
  
      Parameters
      ----------
      X : ndarray or DataFrame of shape n x m
          A matrix of n instances with m features
  
      y : ndarray or Series of length n
          An array or series of target or class values
  
      Returns
      -------
      score_ : float
          Global accuracy score
      """
      # Must be computed before calling super
      # We're relying on predict to raise NotFitted
      y_pred = self.predict(X)
      y_type, y_true, y_pred = _check_targets(y, y_pred)
      if y_type not in ("binary", "multiclass"):
          raise YellowbrickValueError(
              "{} is not supported".format(y_type)
          )
  
      # Get the indices of the unique labels
      indices = unique_labels(y_true, y_pred)
      labels = self._labels()
  
      # Call super to compute self.score_ and verify classes
      try:
          super(ClassPredictionError, self).score(X, y)
      except ModelError as e:
          # raise visualizer-specific errors
          if labels is not None and len(labels) < len(indices):
              raise NotImplementedError(
                  "filtering classes is currently not supported"
              )
          else:
              raise e
  
      # Ensure all labels are used
      if labels is not None and len(labels) > len(indices):
          raise ModelError(
              "y and y_pred contain zero values for one of the specified classes"
          )
  
      # Create a table of predictions whose rows are the true classes
      # and whose columns are the predicted classes; each element
      # is the count of predictions for that class that match the true
      # value of that class.
      self.predictions_ = np.array(
          [
              [
                  (y_pred[y == label_t] == label_p).sum()
                  for label_p in indices
              ]
              for label_t in indices
          ]
      )
  
      self.draw()
      return self.score_
  
file_path: yellowbrick/yellowbrick/classifier/class_prediction_error.py
imports: import numpy
  from sklearn.utils.multiclass import unique_labels
  from yellowbrick.draw import bar_stack
  from yellowbrick.classifier.base import ClassificationScoreVisualizer
  from yellowbrick.exceptions import ModelError, YellowbrickValueError, NotFitted
label_desc: Use image node_id 2 for calling the ClassPredictionError obj's underlying member method code with example usage: obj.score(X, y) and returns: self