Beispiel #1
0
    def plot_result_per_step(self, experiments, show_plot=True, plot_min=None, plot_max=None, title=None):
        """
        Returns (and plots) the plt.figure plotting the results over the steps
        for the specified experiments.

        This includes:
            - one dot per evaluated result at a step
            - a line showing the best result found up to that step for every step
            - error bars for that line

        Parameters
        ----------
        experiments : list of experiment names or experiment name.
            The experiments to plot.
        show_plot : bool, optional
            Whether to show the plot after creation.
        color : string, optional
            A string representing a pyplot color.
        plot_min : float, optional
            The smallest value to plot on the y axis.
        plot_max : float, optional
            The biggest value to plot on the y axis.
        title : string, optional
            The title for the plot. If None, one is autogenerated.

        Returns
        -------
        fig : plt.figure
            The figure containing the results over the steps.
        """
        if not isinstance(experiments, list):
            experiments = [experiments]
        if title is None:
            title = "Comparison of the results of %s." % experiments
        plots_list = []
        for i, exp_id in enumerate(experiments):
            exp_ass = self.exp_assistants[exp_id]
            plots_list.extend(exp_ass._best_result_per_step_dicts(color=COLORS[i % len(COLORS)]))


        if self.exp_assistants[experiments[0]].experiment.minimization_problem:
            legend_loc = 'upper right'
        else:
            legend_loc = 'upper left'
        plot_options = {
            "legend_loc": legend_loc,
            "x_label": "steps",
            "y_label": "result",
            "title": title,
            "minimizing": self.exp_assistants[experiments[0]].experiment.minimization_problem
        }
        fig, ax = plot_lists(plots_list, fig_options=plot_options, plot_min=plot_min, plot_max=plot_max)
        fig.savefig('output1.png')

        if show_plot:
            plt.show(True)

        return fig
Beispiel #2
0
    def plot_result_per_step(self,
                             ax=None,
                             color="b",
                             plot_min=None,
                             plot_max=None):
        """
        Returns the plt.figure plotting the results over the steps.

        Parameters
        ----------
        ax : None or matplotlib.Axes, optional
            The ax to update. If None, a new figure will be created.
        color : string, optional
            A string representing a pyplot color.
        plot_min : float, optional
            The smallest value to plot on the y axis.
        plot_max : float, optional
            The biggest value to plot on the y axis.
        Returns
        -------
        ax: plt.Axes
            The Axes containing the results over the steps.
        """
        self._logger.debug(
            "Plotting result per step. ax %s, colors %s, "
            "plot_min %s, plot_max %s", ax, color, plot_min, plot_max)
        plots = self._best_result_per_step_dicts(color, cutoff_percentage=0.5)
        if self._experiment.minimization_problem:
            legend_loc = 'upper right'
        else:
            legend_loc = 'upper left'
        self._logger.debug("Setting legend to %s LOC", legend_loc)
        plot_options = {
            "legend_loc":
            legend_loc,
            "x_label":
            "steps",
            "y_label":
            "result",
            "title":
            "Plot of %s result over the steps." % (str(self._experiment.name)),
            "minimizing":
            self._experiment.minimization_problem
        }
        self._logger.debug("Plot options are %s", plot_options)
        fig, ax = plot_lists(plots,
                             ax=ax,
                             fig_options=plot_options,
                             plot_min=plot_min,
                             plot_max=plot_max)

        return fig
Beispiel #3
0
    def plot_result_per_step(self, experiments, plot_min=None,
                             plot_max=None, title=None, plot_up_to=None):
        """
        Returns (and plots) the plt.figure plotting the results over the steps
        for the specified experiments.

        Parameters
        ----------
        experiments : list of experiment names or experiment name.
            The experiments to plot.
        show_plot : bool, optional
            Whether to show the plot after creation.
        fig : None or pyplot figure, optional
            The figure to update. If None, a new figure will be created.
        color : string, optional
            A string representing a pyplot color.
        plot_min : float, optional
            The smallest value to plot on the y axis.
        plot_max : float, optional
            The biggest value to plot on the y axis.
        title : string, optional
            The title for the plot. If None, one is autogenerated.

        Returns
        -------
        fig : plt.figure
            The figure containing the results over the steps.
        """
        if not isinstance(experiments, list):
            experiments = [experiments]
        if title is None:
            title = "Comparison of the results of %s." % experiments
        plots_list = []
        for i, exp_id in enumerate(experiments):
            exp_ass = self._exp_assistants[exp_id]
            plots_list.extend(exp_ass._best_result_per_step_dicts(color=COLORS[i % len(COLORS)],
                                                                  plot_up_to=plot_up_to))

        if self._exp_assistants[experiments[0]]._experiment.minimization_problem:
            legend_loc = 'upper right'
        else:
            legend_loc = 'upper left'
        plot_options = {
            "legend_loc": legend_loc,
            "x_label": "steps",
            "y_label": "result",
            "title": title,
            "minimizing": self._exp_assistants[experiments[0]]._experiment.minimization_problem
        }
        fig, ax = plot_lists(plots_list, fig_options=plot_options, plot_min=plot_min, plot_max=plot_max)

        return fig
    def plot_result_per_step(self,
                             experiments,
                             show_plot=True,
                             plot_min=None,
                             plot_max=None,
                             title=None):
        """
        Returns (and plots) the plt.figure plotting the results over the steps
        for the specified experiments.

        This includes:
            - one dot per evaluated result at a step
            - a line showing the best result found up to that step for every step
            - error bars for that line

        Parameters
        ----------
        experiments : list of experiment names or experiment name.
            The experiments to plot.
        show_plot : bool, optional
            Whether to show the plot after creation.
        color : string, optional
            A string representing a pyplot color.
        plot_min : float, optional
            The smallest value to plot on the y axis.
        plot_max : float, optional
            The biggest value to plot on the y axis.
        title : string, optional
            The title for the plot. If None, one is autogenerated.

        Returns
        -------
        fig : plt.figure
            The figure containing the results over the steps.
        """

        best_per_step_plots_list, step_plots_list, plot_options = self._gen_plot_data(
            experiments, title)
        plots_list = []
        plots_list.extend(best_per_step_plots_list)
        plots_list.extend(step_plots_list)

        fig, ax = plot_lists(plots_list,
                             fig_options=plot_options,
                             plot_min=plot_min,
                             plot_max=plot_max)

        if show_plot:
            plt.show(True)

        return fig
Beispiel #5
0
    def plot_result_per_step(self, show_plot=True, ax=None, color="b",
                             plot_min=None, plot_max=None):
        """
        Returns (and plots) the plt.figure plotting the results over the steps.

        Parameters
        ----------
        show_plot : bool, optional
            Whether to show the plot after creation.
        ax : None or matplotlib.Axes, optional
            The ax to update. If None, a new figure will be created.
        color : string, optional
            A string representing a pyplot color.
        plot_min : float, optional
            The smallest value to plot on the y axis.
        plot_max : float, optional
            The biggest value to plot on the y axis.

        Returns
        -------
        ax: plt.Axes
            The Axes containing the results over the steps.
        """


        plots = self._best_result_per_step_dicts(color)
        if self.experiment.minimization_problem:
            legend_loc = 'upper right'
        else:
            legend_loc = 'upper left'

        plot_options = {
            "legend_loc": legend_loc,
            "x_label": "steps",
            "y_label": "result",
            "title": "Plot of %s result over the steps."
                     %(str(self.experiment.name))
        }
        fig, ax = plot_lists(plots, ax=ax, fig_options=plot_options, plot_min=plot_min, plot_max=plot_max)

        if show_plot:
            plt.show(True)

        return ax
    def plot_result_per_step(self, experiments, show_plot=True, plot_min=None, plot_max=None, title=None):
        """
        Returns (and plots) the plt.figure plotting the results over the steps
        for the specified experiments.

        This includes:
            - one dot per evaluated result at a step
            - a line showing the best result found up to that step for every step
            - error bars for that line

        Parameters
        ----------
        experiments : list of experiment names or experiment name.
            The experiments to plot.
        show_plot : bool, optional
            Whether to show the plot after creation.
        color : string, optional
            A string representing a pyplot color.
        plot_min : float, optional
            The smallest value to plot on the y axis.
        plot_max : float, optional
            The biggest value to plot on the y axis.
        title : string, optional
            The title for the plot. If None, one is autogenerated.

        Returns
        -------
        fig : plt.figure
            The figure containing the results over the steps.
        """

        best_per_step_plots_list, step_plots_list, plot_options = self._gen_plot_data(experiments, title)
        plots_list = []
        plots_list.extend(best_per_step_plots_list)
        plots_list.extend(step_plots_list)

        fig, ax = plot_lists(plots_list, fig_options=plot_options, plot_min=plot_min, plot_max=plot_max)
        fig.savefig('output2.png')

        if show_plot:
            plt.show(True)
        return fig
    def plot_result_per_step(self, show_plot=True, ax=None, color="b", plot_min=None, plot_max=None):
        """
        Returns (and plots) the plt.figure plotting the results over the steps.

        Parameters
        ----------
        show_plot : bool, optional
            Whether to show the plot after creation.
        ax : None or matplotlib.Axes, optional
            The ax to update. If None, a new figure will be created.
        color : string, optional
            A string representing a pyplot color.
        plot_min : float, optional
            The smallest value to plot on the y axis.
        plot_max : float, optional
            The biggest value to plot on the y axis.

        Returns
        -------
        ax: plt.Axes
            The Axes containing the results over the steps.
        """

        plots = self._best_result_per_step_dicts(color)
        if self.experiment.minimization_problem:
            legend_loc = "upper right"
        else:
            legend_loc = "upper left"

        plot_options = {
            "legend_loc": legend_loc,
            "x_label": "steps",
            "y_label": "result",
            "title": "Plot of %s result over the steps." % (str(self.experiment.name)),
        }
        fig, ax = plot_lists(plots, ax=ax, fig_options=plot_options, plot_min=plot_min, plot_max=plot_max)

        if show_plot:
            plt.show(True)

        return ax
    def plot_result_per_step(self, ax=None, color="b",
                             plot_min=None, plot_max=None):
        """
        Returns the plt.figure plotting the results over the steps.

        Parameters
        ----------
        ax : None or matplotlib.Axes, optional
            The ax to update. If None, a new figure will be created.
        color : string, optional
            A string representing a pyplot color.
        plot_min : float, optional
            The smallest value to plot on the y axis.
        plot_max : float, optional
            The biggest value to plot on the y axis.
        Returns
        -------
        ax: plt.Axes
            The Axes containing the results over the steps.
        """


        plots = self._best_result_per_step_dicts(color, cutoff_percentage=0.5)
        if self._experiment.minimization_problem:
            legend_loc = 'upper right'
        else:
            legend_loc = 'upper left'

        plot_options = {
            "legend_loc": legend_loc,
            "x_label": "steps",
            "y_label": "result",
            "title": "Plot of %s result over the steps."
                     % (str(self._experiment.name)),
            "minimizing": self._experiment.minimization_problem
        }
        fig, ax = plot_lists(plots, ax=ax, fig_options=plot_options,
                             plot_min=plot_min, plot_max=plot_max)

        return fig
    def plot_result_per_step(self,
                             experiments,
                             show_plot=True,
                             plot_min=None,
                             plot_max=None,
                             title=None):
        """
        Returns (and plots) the plt.figure plotting the results over the steps
        for the specified experiments.

        Parameters
        ----------
        experiments : list of experiment names or experiment name.
            The experiments to plot.
        show_plot : bool, optional
            Whether to show the plot after creation.
        fig : None or pyplot figure, optional
            The figure to update. If None, a new figure will be created.
        color : string, optional
            A string representing a pyplot color.
        plot_min : float, optional
            The smallest value to plot on the y axis.
        plot_max : float, optional
            The biggest value to plot on the y axis.
        title : string, optional
            The title for the plot. If None, one is autogenerated.

        Returns
        -------
        fig : plt.figure
            The figure containing the results over the steps.
        """
        if not isinstance(experiments, list):
            experiments = [experiments]
        if title is None:
            title = "Comparison of %s." % experiments
        plots_list = []
        for i, ex_name in enumerate(experiments):
            exp_ass = self.exp_assistants[ex_name]
            plots_list.extend(
                exp_ass._best_result_per_step_dicts(
                    color=self.COLORS[i % len(self.COLORS)]))

        if self.exp_assistants[experiments[0]].experiment.minimization_problem:
            legend_loc = 'upper right'
        else:
            legend_loc = 'upper left'
        plot_options = {
            "legend_loc": legend_loc,
            "x_label": "steps",
            "y_label": "result",
            "title": title
        }
        fig, ax = plot_lists(plots_list,
                             fig_options=plot_options,
                             plot_min=plot_min,
                             plot_max=plot_max)

        if show_plot:
            plt.show(True)

        return fig