class_docstr: A residual plot shows the residuals on the vertical axis and the
  independent variable on the horizontal axis.
  
  If the points are randomly dispersed around the horizontal axis, a linear
  regression model is appropriate for the data; otherwise, a non-linear
  model is more appropriate.
  
  Parameters
  ----------
  estimator : a Scikit-Learn regressor
      Should be an instance of a regressor, otherwise will raise a
      YellowbrickTypeError exception on instantiation.
      If the estimator 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 None is passed in the current axes
      will be used (or generated if required).
  
  hist : {True, False, None, 'density', 'frequency'}, default: True
      Draw a histogram showing the distribution of the residuals on the
      right side of the figure. Requires Matplotlib >= 2.0.2.
      If set to 'density', the probability density function will be plotted.
      If set to True or 'frequency' then the frequency will be plotted.
  
  qqplot : {True, False}, default: False
      Draw a Q-Q plot on the right side of the figure, comparing the quantiles
      of the residuals against quantiles of a standard normal distribution.
      Q-Q plot and histogram of residuals can not be plotted simultaneously,
      either `hist` or `qqplot` has to be set to False.
  
  train_color : color, default: 'b'
      Residuals for training data are ploted with this color but also
      given an opacity of 0.5 to ensure that the test data residuals
      are more visible. Can be any matplotlib color.
  
  test_color : color, default: 'g'
      Residuals for test data are plotted with this color. In order to
      create generalizable models, reserved test data residuals are of
      the most analytical interest, so these points are highlighted by
      having full opacity. Can be any matplotlib color.
  
  line_color : color, default: dark grey
      Defines the color of the zero error line, can be any matplotlib color.
  
  train_alpha : float, default: 0.75
      Specify a transparency for traininig data, where 1 is completely opaque
      and 0 is completely transparent. This property makes densely clustered
      points more visible.
  
  test_alpha : float, default: 0.75
      Specify a transparency for test data, where 1 is completely opaque
      and 0 is completely transparent. This property makes densely clustered
      points more visible.
  
  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.
  
  kwargs : dict
      Keyword arguments that are passed to the base class and may influence
      the visualization as defined in other Visualizers.
  
  Attributes
  ----------
  
  train_score_ : float
      The R^2 score that specifies the goodness of fit of the underlying
      regression model to the training data.
  
  test_score_ : float
      The R^2 score that specifies the goodness of fit of the underlying
      regression model to the test data.
  
  Examples
  --------
  
  >>> from yellowbrick.regressor import ResidualsPlot
  >>> from sklearn.linear_model import Ridge
  >>> model = ResidualsPlot(Ridge())
  >>> model.fit(X_train, y_train)
  >>> model.score(X_test, y_test)
  >>> model.show()
  
  Notes
  -----
  ResidualsPlot is a ScoreVisualizer, meaning that it wraps a model and
  its primary entry point is the ``score()`` method.
  
  The residuals histogram feature requires matplotlib 2.0.2 or greater.
class_docstr_tok: ["A","residual","plot","shows","the","residuals","on","the","vertical","axis","and","the","independent","variable","on","the","horizontal","axis",".","If","the","points","are","randomly","dispersed","around","the","horizontal","axis",",","a","linear","regression","model","is","appropriate","for","the","data",";","otherwise",",","a","non-linear","model","is","more","appropriate",".","Parameters","--","--","--","--","--","estimator",":","a","Scikit-Learn","regressor","Should","be","an","instance","of","a","regressor",",","otherwise","will","raise","a","YellowbrickTypeError","exception","on","instantiation",".","If","the","estimator","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","None","is","passed","in","the","current","axes","will","be","used","(","or","generated","if","required",")",".","hist",":","{","True",",","False",",","None",",","'density","'",",","'frequency","'","}",",","default",":","True","Draw","a","histogram","showing","the","distribution","of","the","residuals","on","the","right","side","of","the","figure",".","Requires","Matplotlib",">","=","2.0.2",".","If","set","to","'density","'",",","the","probability","density","function","will","be","plotted",".","If","set","to","True","or","'frequency","'","then","the","frequency","will","be","plotted",".","qqplot",":","{","True",",","False","}",",","default",":","False","Draw","a","Q-Q","plot","on","the","right","side","of","the","figure",",","comparing","the","quantiles","of","the","residuals","against","quantiles","of","a","standard","normal","distribution",".","Q-Q","plot","and","histogram","of","residuals","can","not","be","plotted","simultaneously",",","either","`","hist","`","or","`","qqplot","`","has","to","be","set","to","False",".","train_color",":","color",",","default",":","'","b'","Residuals","for","training","data","are","ploted","with","this","color","but","also","given","an","opacity","of","0.5","to","ensure","that","the","test","data","residuals","are","more","visible",".","Can","be","any","matplotlib","color",".","test_color",":","color",",","default",":","'","g'","Residuals","for","test","data","are","plotted","with","this","color",".","In","order","to","create","generalizable","models",",","reserved","test","data","residuals","are","of","the","most","analytical","interest",",","so","these","points","are","highlighted","by","having","full","opacity",".","Can","be","any","matplotlib","color",".","line_color",":","color",",","default",":","dark","grey","Defines","the","color","of","the","zero","error","line",",","can","be","any","matplotlib","color",".","train_alpha",":","float",",","default",":","0.75","Specify","a","transparency","for","traininig","data",",","where","1","is","completely","opaque","and","0","is","completely","transparent",".","This","property","makes","densely","clustered","points","more","visible",".","test_alpha",":","float",",","default",":","0.75","Specify","a","transparency","for","test","data",",","where","1","is","completely","opaque","and","0","is","completely","transparent",".","This","property","makes","densely","clustered","points","more","visible",".","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",".","kwargs",":","dict","Keyword","arguments","that","are","passed","to","the","base","class","and","may","influence","the","visualization","as","defined","in","other","Visualizers",".","Attributes","--","--","--","--","--","train_score_",":","float","The","R^2","score","that","specifies","the","goodness","of","fit","of","the","underlying","regression","model","to","the","training","data",".","test_score_",":","float","The","R^2","score","that","specifies","the","goodness","of","fit","of","the","underlying","regression","model","to","the","test","data",".","Examples","--","--","--","--",">",">",">","from","yellowbrick.regressor","import","ResidualsPlot",">",">",">","from","sklearn.linear_model","import","Ridge",">",">",">","model","=","ResidualsPlot","(","Ridge","(",")",")",">",">",">","model.fit","(","X_train",",","y_train",")",">",">",">","model.score","(","X_test",",","y_test",")",">",">",">","model.show","(",")","Notes","--","--","-","ResidualsPlot","is","a","ScoreVisualizer",",","meaning","that","it","wraps","a","model","and","its","primary","entry","point","is","the","``","score","(",")","``","method",".","The","residuals","histogram","feature","requires","matplotlib","2.0.2","or","greater","."]
code: def __init__(
      self,
      estimator,
      ax=None,
      hist=True,
      qqplot=False,
      train_color="b",
      test_color="g",
      line_color=LINE_COLOR,
      train_alpha=0.75,
      test_alpha=0.75,
      is_fitted="auto",
      **kwargs,
  ):
      # Initialize the visualizer base
      super(ResidualsPlot, self).__init__(
          estimator, ax=ax, is_fitted=is_fitted, **kwargs
      )
  
      # TODO: allow more scatter plot arguments for train and test points
      # See #475 (RE: ScatterPlotMixin)
      self.colors = {
          "train_point": train_color,
          "test_point": test_color,
          "line": line_color,
      }
  
      self.hist = hist
      if self.hist not in {True, "density", "frequency", None, False}:
          raise YellowbrickValueError(
              "'{}' is an invalid argument for hist, use None, True, "
              "False, 'density', or 'frequency'".format(hist)
          )
  
      self.qqplot = qqplot
      if self.qqplot not in {True, False}:
          raise YellowbrickValueError(
              "'{}' is an invalid argument for qqplot, use True, "
              " or False".format(hist)
          )
  
      if self.hist in {
          True,
          "density",
          "frequency",
      } and self.qqplot in {True}:
          raise YellowbrickValueError(
              "Set either hist or qqplot to False, can not plot "
              "both of them simultaneously."
          )
  
      if self.hist in {True, "density", "frequency"}:
          self.hax  # If hist is True, test the version availability
  
      if self.qqplot in {True}:
          self.qqax  # If qqplot is True, test the version availability
  
      # Store labels and colors for the legend ordered by call
      self._labels, self._colors = [], []
  
      self.alphas = {
          "train_point": train_alpha,
          "test_point": test_alpha,
      }
  
file_path: yellowbrick/yellowbrick/regressor/residuals.py
imports: import matplotlib.pyplot
  from scipy.stats import probplot
  from yellowbrick.draw import manual_legend
  from yellowbrick.utils.decorators import memoized
  from yellowbrick.style.palettes import LINE_COLOR
  from yellowbrick.exceptions import YellowbrickValueError
  from yellowbrick.regressor.base import RegressionScoreVisualizer
label_desc: Use image node_id 1 to create a new ResidualsPlot object from inherited base classes: RegressionScoreVisualizer with example: obj = ResidualsPlot(estimator, ax, hist, qqplot, train_color, test_color, line_color, train_alpha, test_alpha, is_fitted)