Beispiel #1
0
    def plot_diagnostics(self, absolute=False):

        plot_residuals(residual_array=self.r_mean, group_name='Overall mean', absolute=absolute)
        if self.r_std is not None:
            plot_residuals(residual_array=self.r_std, group_name='Overall std', absolute=True)
        if self.r_mad is not None:
            plot_residuals(residual_array=self.r_mad, group_name='Overall mad', absolute=True)
        for k, v in self.pv_groups.items():
            plot_residuals(residual_array=v.residuals, group_name=k, absolute=absolute)
Beispiel #2
0
    def triangle_residual_plots(self,
                                radius,
                                x_axis='far_out',
                                y_axis='num_data',
                                exclude=None,
                                absolute=False):
        """
        Plot all of the residuals based on some exclusion criteria for
        number of data points that were used in the fitting and some radius
        for smoothing over a window of neighboring data density / number predicting out.

        Args:
            radius: List[int]
            absolute: (bool) plot mean residuals by value or absolute value
            exclude: (int) exclude model fits with under this many data points
            x_axis: (str) the x-axis variable to plot (one of far_out, num_data, or data_index)
            y_axis: (str) the y-axis variable to plot (one of far_out, num_data, or data_index)
        """
        smoothed_residuals = self.get_smoothed_residuals(radius=radius)
        smoothed_residuals = smoothed_residuals.loc[
            smoothed_residuals['num_data'] > exclude].copy()

        for i, (k, v) in enumerate(self.pv_groups.items()):

            residuals = self.all_residuals.loc[self.all_residuals[
                self.col_group] == k].copy()
            plot_residuals(residual_array=np.asarray(
                residuals[[x_axis, y_axis, 'residual']]),
                           group_name=k,
                           absolute=absolute,
                           x_label=x_axis,
                           y_label=y_axis)

            smooth = smoothed_residuals.loc[smoothed_residuals[self.col_group]
                                            == k]
            smooth_mean = np.asarray(smooth[[x_axis, y_axis, 'residual_mean']])
            smooth_std = np.asarray(smooth[[x_axis, y_axis, 'residual_std']])
            plot_residuals(residual_array=smooth_mean,
                           group_name=f'{k} smooth mean radius {radius}',
                           absolute=absolute,
                           x_label=x_axis,
                           y_label=y_axis)
            plot_residuals(residual_array=smooth_std,
                           group_name=f'{k} smooth std radius {radius}',
                           absolute=True,
                           x_label=x_axis,
                           y_label=y_axis)
Beispiel #3
0
    def plot_residuals(self, radius, absolute=False, exclude=5):
        """
        Plot all of the residuals based on some exclusion criteria for
        number of data points that were used in the fitting and some radius
        for smoothing over a window of neighboring data density / number predicting out.

        Args:
            radius: List[int]
            absolute: (bool) plot mean residuals by value or absolute value
            exclude: (int) exclude model fits with under this many data points
        """
        smoothed_residuals = self.get_smoothed_residuals(radius=radius)
        smoothed_residuals = smoothed_residuals.loc[smoothed_residuals['num_data'] > exclude].copy()

        for k, v in self.pv_groups.items():
            plot_residuals(residual_array=v.residuals, group_name=k, absolute=absolute)
            smooth = smoothed_residuals.loc[smoothed_residuals[self.col_group] == k]
            smooth_mean = np.asarray(smooth[['far_out', 'num_data', 'residual_mean']])
            smooth_std = np.asarray(smooth[['far_out', 'num_data', 'residual_std']])
            plot_residuals(residual_array=smooth_mean,
                           group_name=f'{k} smooth mean radius {radius}', absolute=absolute)
            plot_residuals(residual_array=smooth_std,
                           group_name=f'{k} smooth std radius {radius}', absolute=True)