Exemplo n.º 1
0
    def __init__(self, api_config, **kwargs):
        """Build wrapper class to use an optimizer in benchmark.

        Parameters
        ----------
        api_config : dict-like of dict-like
            Configuration of the optimization variables. See API description.
        """
        AbstractOptimizer.__init__(self, api_config)
        self.opt1 = HyperoptOptimizer(api_config, **kwargs)
        self.opt2 = ScikitOptimizer(api_config)
Exemplo n.º 2
0
class SKHyperOptimizer(AbstractOptimizer):
    def __init__(self, api_config, **kwargs):
        """Build wrapper class to use an optimizer in benchmark.

        Parameters
        ----------
        api_config : dict-like of dict-like
            Configuration of the optimization variables. See API description.
        """
        AbstractOptimizer.__init__(self, api_config)
        self.opt1 = HyperoptOptimizer(api_config, **kwargs)
        self.opt2 = ScikitOptimizer(api_config)

    def suggest(self, n_suggestions=1):
        t_out = self.opt1.suggest(n_suggestions)
        s_out = self.opt2.suggest(n_suggestions)
        N = len(t_out) // 2
        return t_out[:N] + s_out[N:]

    def observe(self, X, y):
        self.opt1.observe(X, y)
        self.opt2.observe(X, y)