示例#1
0
    def run(self, X, y):
        super(Joint, self).run(X, y)
        current_pipeline_configuration = {}
        current_algo_configuration = {}
        trials = Trials()
        algorithm = self.config['algorithm']
        space = {
            'pipeline': self.PIPELINE_SPACE,
            'algorithm': ALGORITHM_SPACE.get_domain_space(algorithm),
        }
        obj_pl = functools.partial(objective_joint,
                algorithm=self.config['algorithm'],
                X=X,
                y=y,
                context=self.context,
                config=self.config)
        fmin(
            fn=obj_pl, 
            space=space, 
            algo=tpe.suggest, 
            max_evals=None,
            max_time=self.config['time'],     
            trials=trials,
            show_progressbar=False,
            verbose=0
        )

        best_config = self.context['best_config']
        super(Joint, self).display_step_results(best_config)
        current_pipeline_configuration = best_config['pipeline']
    def run(self, X, y):
        super(Iterative, self).run(X, y)
        ranges = [
            i for i in range(
                0, self.config['time'] /
                (self.config['step_pipeline'] + self.config['step_algorithm']))
        ]
        current_pipeline_configuration = {}
        current_algo_configuration = {}
        trials_pipelines = Trials()
        trials_algo = Trials()
        reset_trial = False
        for r in ranges:
            print('## Data Pipeline')
            if reset_trial:
                trials_pipelines = Trials()
            obj_pl = functools.partial(
                objective_pipeline,
                current_algo_config=current_algo_configuration,
                algorithm=self.config['algorithm'],
                X=X,
                y=y,
                context=self.context,
                config=self.config)
            fmin(fn=obj_pl,
                 space=self.PIPELINE_SPACE,
                 algo=tpe.suggest,
                 max_evals=None,
                 max_time=self.config['step_pipeline'],
                 trials=trials_pipelines,
                 show_progressbar=False,
                 verbose=0)
            best_config = self.context['best_config']
            current_pipeline_configuration = best_config['pipeline']
            super(Iterative, self).display_step_results(best_config)

            print('## Algorithm')
            if reset_trial:
                trials_algo = Trials()
            obj_algo = functools.partial(
                objective_algo,
                current_pipeline_config=current_pipeline_configuration,
                algorithm=self.config['algorithm'],
                X=X,
                y=y,
                context=self.context,
                config=self.config)
            fmin(fn=obj_algo,
                 space=ALGORITHM_SPACE.get_domain_space(
                     self.config['algorithm']),
                 algo=tpe.suggest,
                 max_evals=None,
                 max_time=self.config['step_algorithm'],
                 trials=trials_algo,
                 show_progressbar=False,
                 verbose=0)
            best_config = self.context['best_config']
            current_pipeline_configuration = best_config['pipeline']
            super(Iterative, self).display_step_results(best_config)
示例#3
0
    def run(self, X, y):
        super(Adaptive, self).run(X, y)
        current_pipeline_configuration = {}
        current_algo_configuration = {}
        trials_pipelines = Trials()
        trials_algo = Trials()
        timeout = False
        start = time.time()
        remaining = self.config['time']
        while not timeout:
            ellapsed = time.time() - start
            remaining = self.config['time'] - ellapsed
            timeout = remaining < 0
            print('## Data Pipeline')
            step_start = time.time()
            if self.__reset_trials('pipeline'):
                trials_pipelines = Trials()
            obj_pl = functools.partial(
                objective_pipeline,
                current_algo_config=current_algo_configuration,
                algorithm=self.config['algorithm'],
                X=X,
                y=y,
                context=self.context,
                config=self.config)
            try:
                fmin(fn=obj_pl,
                     space=PIPELINE_SPACE,
                     algo=tpe.suggest,
                     max_evals=None,
                     max_time=self.current_steptime['pipeline'],
                     trials=trials_pipelines,
                     show_progressbar=False,
                     verbose=0)
            except Exception as e:
                pass
            best_config = self.context['best_config']
            current_pipeline_configuration = best_config['pipeline']
            super(Adaptive, self).display_step_results(best_config)
            self.__determine_last_step(step_start)
            self.__score_last_step()
            self.__update_timestep('pipeline')

            print('## Algorithm')
            step_start = time.time()
            if self.__reset_trials('algorithm'):
                trials_algo = Trials()
            obj_algo = functools.partial(
                objective_algo,
                current_pipeline_config=current_pipeline_configuration,
                algorithm=self.config['algorithm'],
                X=X,
                y=y,
                context=self.context,
                config=self.config)
            try:
                fmin(fn=obj_algo,
                     space=ALGORITHM_SPACE.get_domain_space(
                         self.config['algorithm']),
                     algo=tpe.suggest,
                     max_evals=None,
                     max_time=self.current_steptime['algorithm'],
                     trials=trials_algo,
                     show_progressbar=False,
                     verbose=0)
            except Exception as e:
                pass
            best_config = self.context['best_config']
            current_pipeline_configuration = best_config['pipeline']
            super(Adaptive, self).display_step_results(best_config)
            self.__determine_last_step(step_start)
            self.__score_last_step()
            self.__update_timestep('algorithm')
        self.context['current_steptime'] = self.current_steptime
        self.context['history_steps_score'] = self.history_steps_score