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: Adds a title and axis labels to the visualizer, ensuring that the
  y limits zoom the visualization in to the area of interest. Finalize
  also calls tight layout to ensure that no parts of the figure are
  cut off.
  
  Notes
  -----
  Generally this method is called from show and not directly by the user.
docstr_tok: ["Adds","a","title","and","axis","labels","to","the","visualizer",",","ensuring","that","the","y","limits","zoom","the","visualization","in","to","the","area","of","interest",".","Finalize","also","calls","tight","layout","to","ensure","that","no","parts","of","the","figure","are","cut","off",".","Notes","--","--","-","Generally","this","method","is","called","from","show","and","not","directly","by","the","user","."]
code: def finalize(self, **kwargs):
      """
      Adds a title and axis labels to the visualizer, ensuring that the
      y limits zoom the visualization in to the area of interest. Finalize
      also calls tight layout to ensure that no parts of the figure are
      cut off.
  
      Notes
      -----
      Generally this method is called from show and not directly by the user.
      """
  
      # Set the title
      self.set_title("Class Prediction Error for {}".format(self.name))
  
      # Set the axes labels
      self.ax.set_xlabel("actual class")
      self.ax.set_ylabel("number of predicted class")
  
      # Compute the ceiling for the y limit
      cmax = max(
          [sum(predictions) for predictions in self.predictions_]
      )
      self.ax.set_ylim(0, cmax + cmax * 0.1)
  
      # Ensure the legend fits on the figure
      self.fig.tight_layout(rect=[0, 0, 0.90, 1])
  
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 4 for calling the ClassPredictionError obj's underlying member method code with example usage: obj.finalize() without return types