Ejemplo n.º 1
0
    def _plot_result(fANOVA, configspace, directory, yrange=None):
        vis = Visualizer(fANOVA, configspace)

        try:
            os.makedirs(directory)
        except FileExistsError:
            pass

        for hp in configspace.get_hyperparameters():
            plt.close('all')
            plt.clf()
            param = hp.name
            outfile_name = os.path.join(directory,
                                        param.replace(os.sep, "_") + ".pdf")
            if isinstance(hp, (CategoricalHyperparameter)):
                vis.plot_categorical_marginal(
                    configspace.get_idx_by_hyperparameter_name(param),
                    show=False,
                    ylabel='Predictive Accuracy')
            else:
                vis.plot_marginal(
                    configspace.get_idx_by_hyperparameter_name(param),
                    resolution=100,
                    show=False,
                    ylabel='Predictive Accuracy')
            x1, x2, _, _ = plt.axis()
            if yrange:
                plt.axis((x1, x2, yrange[0], yrange[1]))
            plt.savefig(outfile_name)
        pass
Ejemplo n.º 2
0
    def plot_result(self, name='fANOVA', show=True):
        if not os.path.exists(name):
            os.mkdir(name)

        vis = Visualizer(self.evaluator,
                         self.cs,
                         directory=name,
                         y_label=self._get_label(self.scenario.run_obj))
        self.logger.info('Getting Marginals!')
        pbar = tqdm(range(self.to_evaluate),
                    ascii=True,
                    disable=not self.verbose)
        for i in pbar:
            plt.close('all')
            plt.clf()
            param = list(self.evaluated_parameter_importance.keys())[i]
            # Plot once in log, once linear
            for mode in [(True, '_log'), (False, '')]:
                outfile_name = os.path.join(
                    name,
                    param.replace(os.sep, "_") + mode[1] + ".png")
                # The try/except clause is only for back-compatibility with fanova <= 2.0.11
                try:
                    vis.plot_marginal(
                        self.cs.get_idx_by_hyperparameter_name(param),
                        log_scale=mode[0],
                        show=False,
                        incumbents=self.incumbents)
                except TypeError:
                    self.logger.debug(
                        "Plotting incumbents not supported by fanova < 2.0.12")
                    vis.plot_marginal(
                        self.cs.get_idx_by_hyperparameter_name(param),
                        log_scale=mode[0],
                        show=False)
                fig = plt.gcf()
                fig.savefig(outfile_name)
                plt.close('all')
                plt.clf()
            if show:
                plt.show()
            pbar.set_description('Creating fANOVA plot: {: <.30s}'.format(
                outfile_name.split(os.path.sep)[-1]))
        if self.pairwise:
            self.logger.info('Plotting Pairwise-Marginals!')
            most_important_ones = list(
                self.evaluated_parameter_importance.keys(
                ))[:min(self.num_single, self.n_most_imp_pairs)]
            vis.create_most_important_pairwise_marginal_plots(
                most_important_ones)
            try:
                vis.create_most_important_pairwise_marginal_plots(
                    most_important_ones)
            except TypeError as err:
                self.logger.debug(err, exc_info=1)
                self.logger.warning('Could not create pairwise plots!')
            plt.close('all')
Ejemplo n.º 3
0
    def plot_result(self, name='fANOVA', show=True):
        if not os.path.exists(name):
            os.mkdir(name)

        if self.scenario.run_obj == 'runtime':
            label = 'runtime [sec]'
        elif self.scenario.run_obj == 'quality':
            label = 'cost'
        else:
            label = '%s' % self.scenario.run_obj
        vis = Visualizer(self.evaluator,
                         self.cs,
                         directory=name,
                         y_label=label)
        self.logger.info('Getting Marginals!')
        pbar = tqdm(range(self.to_evaluate),
                    ascii=True,
                    disable=not self.verbose)
        for i in pbar:
            plt.close('all')
            plt.clf()
            param = list(self.evaluated_parameter_importance.keys())[i]
            outfile_name = os.path.join(name,
                                        param.replace(os.sep, "_") + ".png")
            vis.plot_marginal(self.cs.get_idx_by_hyperparameter_name(param),
                              log_scale=False,
                              show=False)
            fig = plt.gcf()
            fig.savefig(outfile_name)
            plt.close('all')
            plt.clf()
            outfile_name = os.path.join(
                name,
                param.replace(os.sep, "_") + "_log.png")
            vis.plot_marginal(self.cs.get_idx_by_hyperparameter_name(param),
                              log_scale=True,
                              show=False)
            fig = plt.gcf()
            fig.savefig(outfile_name)
            plt.close('all')
            plt.clf()
            if show:
                plt.show()
            pbar.set_description('Creating fANOVA plot: {: <.30s}'.format(
                outfile_name.split(os.path.sep)[-1]))
        if self.pairwise:
            self.logger.info('Plotting Pairwise-Marginals!')
            most_important_ones = list(
                self.evaluated_parameter_importance.keys(
                ))[:min(self.num_single, self.n_most_imp_pairs)]
            try:
                vis.create_most_important_pairwise_marginal_plots(
                    most_important_ones)
            except TypeError:
                self.logger.warning('Could not create pairwise plots!')
            plt.close('all')
Ejemplo n.º 4
0
    def _plot_result(fANOVA, configspace, directory, yrange=None):
        os.makedirs(directory, exist_ok=True)
        vis = Visualizer(fANOVA, configspace, directory, y_label='Predictive Accuracy')

        for hp1 in configspace.get_hyperparameters():
            plt.close('all')
            plt.clf()
            param = hp1.name
            outfile_name = os.path.join(directory, param.replace(os.sep, "_") + ".pdf")
            vis.plot_marginal(configspace.get_idx_by_hyperparameter_name(param), show=False)

            x1, x2, _, _ = plt.axis()
            if yrange:
                plt.axis((x1, x2, yrange[0], yrange[1]))
            plt.savefig(outfile_name)

        pass
Ejemplo n.º 5
0
 def plot_result(self, name='fANOVA', show=True):
     if not os.path.exists(name):
         os.mkdir(name)
     vis = Visualizer(self.evaluator, self.cs, directory=name)
     self.logger.info('Getting Marginals!')
     for i in range(self.to_evaluate):
         plt.close('all')
         plt.clf()
         param = list(self.evaluated_parameter_importance.keys())[i]
         outfile_name = os.path.join(name,
                                     param.replace(os.sep, "_") + ".png")
         vis.plot_marginal(self.cs.get_idx_by_hyperparameter_name(param),
                           show=False)
         fig = plt.gcf()
         fig.savefig(outfile_name)
         if show:
             plt.show()
         self.logger.info('Creating fANOVA plot: %s' % outfile_name)
     self.logger.info('Plotting Pairwise-Marginals!')
     most_important_ones = list(self.evaluated_parameter_importance.keys(
     ))[:min(self.num_single, self.n_most_imp_pairs)]
     vis.create_most_important_pairwise_marginal_plots(most_important_ones)
     plt.close('all')
Ejemplo n.º 6
0
 def plot_result(self, name='fANOVA'):
     vis = Visualizer(self.evaluator, self.cs)
     if not os.path.exists(name):
         os.mkdir(name)
     self.logger.info('Getting Marginals!')
     for i in range(self.to_evaluate):
         plt.close('all')
         plt.clf()
         param = list(self.evaluated_parameter_importance.keys())[i]
         outfile_name = os.path.join(name,
                                     param.replace(os.sep, "_") + ".png")
         if isinstance(self.cs.get_hyperparameter(param),
                       (CategoricalHyperparameter)):
             vis.plot_categorical_marginal(
                 self.cs.get_idx_by_hyperparameter_name(param), show=False)
         else:
             vis.plot_marginal(
                 self.cs.get_idx_by_hyperparameter_name(param), show=False)
         plt.savefig(outfile_name)
         self.logger.info('Creating fANOVA plot: %s' % outfile_name)
     self.logger.info('Getting Pairwise-Marginals!')
     self.logger.info('This will take some time!')
     vis.create_most_important_pairwise_marginal_plots(
         name, self.to_evaluate)