def plot_cost(self, figure_id=None, new_figure=False, **kwargs):
     r"""
     Plots the cost evolution throughout the fitting.
     """
     legend = self.algorithm
     x_label = 'Number of iterations'
     y_label = 'Normalized cost'
     return GraphPlotter(figure_id, new_figure, range(0, self.n_iters+1),
                         [self.costs], legend=legend, x_label=x_label,
                         y_label=y_label).render(**kwargs)
 def plot_error(self, figure_id=None, new_figure=False, **kwargs):
     r"""
     Plots the error evolution throughout the fitting.
     """
     if self.gt_shape is not None:
         legend = [self.algorithm]
         x_label = 'Number of iterations'
         y_label = self._error_text
         return GraphPlotter(figure_id, new_figure,
                             range(0, self.n_iters+1), [self.errors],
                             legend=legend, x_label=x_label,
                             y_label=y_label).render(**kwargs)
     else:
         raise ValueError('Ground truth has not been set, error '
                          'cannot be plotted')
 def _plot_dist(self, x_axis, y_axis, title, figure_id=None,
                new_figure=False, y_limit=1, **kwargs):
     legend = [self.algorithm +
               '\nmean: {0:.4f}'.format(self.final_mean_error) +
               'std: {0:.4f}, '.format(self.final_std_error) +
               'median: {0:.4f}, '.format(self.final_median_error) +
               'convergence: {0:.2f}, '.format(self.convergence),
               'Initialization' +
               '\nmean: {0:.4f}, '.format(self.initial_mean_error) +
               'std: {0:.4f}, '.format(self.initial_std_error) +
               'median: {0:.4f}, '.format(self.initial_median_error)]
     x_label = self._error_text
     y_label = 'Proportion of images'
     axis_limits = [0, self._error_stop, 0, y_limit]
     return GraphPlotter(figure_id, new_figure, x_axis, y_axis,
                         title=title, legend=legend,
                         x_label=x_label, y_label=y_label,
                         axis_limits=axis_limits).render(**kwargs)
Exemple #4
0
 def plot_cost(self, figure_id=None, new_figure=False, **kwargs):
     r"""
     Plots the cost evolution throughout the fitting.
     """
     title = 'Cost evolution'
     legend = self.algorithm
     x_label = 'Number of iterations'
     y_label = 'Normalized cost'
     costs = [c for cost in self.costs for c in cost]
     total_n_iters = self.n_iters + self.n_levels
     axis_limits = [0, total_n_iters, 0, max(costs)]
     return GraphPlotter(figure_id,
                         new_figure,
                         range(0, self.n_iters + self.n_levels),
                         costs,
                         title=title,
                         legend=legend,
                         x_label=x_label,
                         y_label=y_label,
                         axis_limits=axis_limits).render(**kwargs)
Exemple #5
0
 def plot_error(self, figure_id=None, new_figure=False, **kwargs):
     r"""
     Plots the error evolution throughout the fitting.
     """
     if self.gt_shape is not None:
         title = 'Error evolution'
         legend = [self.algorithm]
         x_label = 'Number of iterations'
         y_label = self._error_text
         errors = self.errors
         x_limit = self.n_iters + self.n_levels
         axis_limits = [0, x_limit, 0, np.max(errors)]
         return GraphPlotter(figure_id,
                             new_figure,
                             range(0, x_limit), [errors],
                             title=title,
                             legend=legend,
                             x_label=x_label,
                             y_label=y_label,
                             axis_limits=axis_limits).render(**kwargs)
     else:
         raise ValueError('Ground truth shape has not been set, error '
                          'cannot be plotted')
Exemple #6
0
def plot_fitting_curves(x_axis,
                        ceds,
                        title,
                        figure_id=None,
                        new_figure=False,
                        x_label='Point-to-Point Normalized RMS Error',
                        y_limit=1,
                        x_limit=0.05,
                        legend=None,
                        **kwargs):
    r"""
    Method that plots Cumulative Error Distributions in a single figure.

    Parameters
    ----------
    x_axis: ndarray
        The horizontal axis values (errors).
    ceds: list of ndarrays
        The vertical axis values (percentages).
    title: string
        The plot title.
    figure_id, Optional
        A figure handle.

        Default: None
    new_figure: boolean, Optional
        If True, a new figure window will be created.

        Default: False
    y_limit: float, Optional
        The maximum value of the vertical axis.

        Default: 1
    x_limit: float, Optional
        The maximum value of the vertical axis.

        Default: 0.05
    x_label: string
        The label of the horizontal axis.

        Default: 'Point-to-Point Normalized RMS Error'
    legend: list of strings or None
        The legend of the plot. If None, the legend will include an incremental
        number per curve.

        Default: None

    Returns
    -------
    final_error_dist: list
        Cumulative distribution values of the final errors.
    initial_error_dist: list
        Cumulative distribution values of the initial errors.
    """
    if legend is None:
        legend = [str(i + 1) for i in range(len(ceds))]
    y_label = 'Proportion of images'
    axis_limits = [0, x_limit, 0, y_limit]
    return GraphPlotter(figure_id,
                        new_figure,
                        x_axis,
                        ceds,
                        title=title,
                        legend=legend,
                        x_label=x_label,
                        y_label=y_label,
                        axis_limits=axis_limits).render(**kwargs)