コード例 #1
0
    def plot_predicted(self, xlab="fitted", ylab="actual"):
        """A plot of predicted values vs actual values.

        """
        fig, ax = R.plot(self.fitted_values,
                         self.residuals + self.fitted_values,
                         xlab=xlab,
                         ylab=ylab)
        return fig, ax
コード例 #2
0
    def plot_residual(self,
                      hexbin_threshold=1e+5,
                      xlab="fitted",
                      ylab="residual"):
        """A plot of the residuals vs the predicted values.

        """
        fig, ax = R.plot(self.fitted_values,
                         self.residuals,
                         hexbin_threshold=hexbin_threshold,
                         xlab=xlab,
                         ylab=ylab)
        if len(self.residuals) > hexbin_threshold:
            abs_resid = np.abs(self.residuals)
            n = len(abs_resid) - 100
            top_resids = np.argpartition(abs_resid, n)[n:]
            ax.scatter(self.fitted_values[top_resids],
                       self.residuals[top_resids],
                       s=5,
                       color="yellow")
        ax.axhline(color="black", linewidth=.5)
        return fig, ax