def draw(self, y_pred, residuals, train=False, **kwargs):
        """
        Draw the residuals against the predicted value for the specified split.
        It is best to draw the training split first, then the test split so
        that the test split (usually smaller) is above the training split;
        particularly if the histogram is turned on.

        Parameters
        ----------
        y_pred : ndarray or Series of length n
            An array or series of predicted target values

        residuals : ndarray or Series of length n
            An array or series of the difference between the predicted and the
            target values

        train : boolean, default: False
            If False, `draw` assumes that the residual points being plotted
            are from the test data; if True, `draw` assumes the residuals
            are the train data.

        Returns
        ------
        ax : the axis with the plotted figure
        """

        if train:
            color = self.colors['train_point']
            label = "Train $R^2 = {:0.3f}$".format(self.train_score_)
            alpha = self.alphas['train_point']
        else:
            color = self.colors['test_point']
            label = "Test $R^2 = {:0.3f}$".format(self.test_score_)
            alpha = self.alphas['test_point']
            
        # Update the legend information
        self._labels.append(label)
        self._colors.append(color)

        # Draw the residuals scatter plot
        self.ax.scatter(
            y_pred, residuals, c=color, alpha=alpha, label=label
        )

        # Add residuals histogram
        if self.hist in {True, 'frequency'}:
            self.hax.hist(residuals, bins=50, orientation="horizontal", color=color)
        elif self.hist == 'density':
            self.hax.hist(
                residuals, bins=50, orientation="horizontal", density=True, color=color
            )

        # Ensure the current axes is always the main residuals axes
        plt.sca(self.ax)
        return self.ax
def draw ( self , y_pred , residuals , train = False , ** kwargs ) : if train : color = self . colors [ 'train_point' ] label = "Train $R^2 = {:0.3f}$" . format ( self . train_score_ ) alpha = self . alphas [ 'train_point' ] else : color = self . colors [ 'test_point' ] label = "Test $R^2 = {:0.3f}$" . format ( self . test_score_ ) alpha = self . alphas [ 'test_point' ] self . _labels . append ( label ) self . _colors . append ( color ) self . ax . scatter ( y_pred , residuals , c = color , alpha = alpha , label = label ) if self . hist in { True , 'frequency' } : self . hax . hist ( residuals , bins = 50 , orientation = "horizontal" , color = color ) elif self . hist == 'density' : self . hax . hist ( residuals , bins = 50 , orientation = "horizontal" , density = True , color = color ) plt . sca ( self . ax ) return self . ax
Draw the residuals against the predicted value for the specified split.
        It is best to draw the training split first, then the test split so
        that the test split (usually smaller) is above the training split;
        particularly if the histogram is turned on.

        Parameters
        ----------
        y_pred : ndarray or Series of length n
            An array or series of predicted target values

        residuals : ndarray or Series of length n
            An array or series of the difference between the predicted and the
            target values

        train : boolean, default: False
            If False, `draw` assumes that the residual points being plotted
            are from the test data; if True, `draw` assumes the residuals
            are the train data.

        Returns
        ------
        ax : the axis with the plotted figure