class_docstr: .. include:: /global.rst
  
  This solver provides an interface to BayesOpt, as described in [BO2014]_.
  This solver uses BayesOpt in the back-end and exposes its solver with uniform priors.
  
  Please refer to |bayesopt| for details about this algorithm.
  
  .. note::
  
      This solver will always output some text upon running.
      This is caused internally by BayesOpt, which provides no way to disable all output.
  
  .. [BO2014] Martinez-Cantin, Ruben. "BayesOpt: A Bayesian optimization library for nonlinear optimization, experimental design and bandits." The Journal of Machine Learning Research 15.1 (2014): 3735-3739.
class_docstr_tok: ["..","include",":",":","\/global.rst","This","solver","provides","an","interface","to","BayesOpt",",","as","described","in","[","BO2014","]","_",".","This","solver","uses","BayesOpt","in","the","back-end","and","exposes","its","solver","with","uniform","priors",".","Please","refer","to","|bayesopt|","for","details","about","this","algorithm",".","..","note",":",":","This","solver","will","always","output","some","text","upon","running",".","This","is","caused","internally","by","BayesOpt",",","which","provides","no","way","to","disable","all","output",".","..","[","BO2014","]","Martinez-Cantin",",","Ruben",".","``","BayesOpt",":","A","Bayesian","optimization","library","for","nonlinear","optimization",",","experimental","design","and","bandits",".","''","The","Journal","of","Machine","Learning","Research","15.1","(","2014",")",":","3735-3739","."]
docstr: Initialize the BayesOpt solver.
  
  :param num_evals: number of permitted function evaluations
  :type num_evals: int
  :param seed: the random seed to be used
  :type seed: double
  :param kwargs: box constraints for each hyperparameter
  :type kwargs: {'name': [lb, ub], ...}
docstr_tok: ["Initialize","the","BayesOpt","solver",".",":","param","num_evals",":","number","of","permitted","function","evaluations",":","type","num_evals",":","int",":","param","seed",":","the","random","seed","to","be","used",":","type","seed",":","double",":","param","kwargs",":","box","constraints","for","each","hyperparameter",":","type","kwargs",":","{","'name","'",":","[","lb",",","ub","]",",","...","}"]
code: def __init__(self, num_evals=100, seed=None, **kwargs):
      """
  
      Initialize the BayesOpt solver.
  
      :param num_evals: number of permitted function evaluations
      :type num_evals: int
      :param seed: the random seed to be used
      :type seed: double
      :param kwargs: box constraints for each hyperparameter
      :type kwargs: {'name': [lb, ub], ...}
  
  
      """
      if not _bayesopt_available:
          raise ImportError(
              "This solver requires bayesopt but it is missing."
          )
      if not _numpy_available:
          raise ImportError(
              "This solver requires NumPy but it is missing."
          )
  
      self._seed = seed
      self._bounds = kwargs
      self._num_evals = num_evals
      # bayesopt does not support open intervals,
      # while optunity uses open intervals
      # so we manually shrink the bounding box slightly (yes, this is a dirty fix)
      delta = 0.001
      self._lb = np.array(
          map(
              lambda x: float(x[1][0] + delta * (x[1][1] - x[1][0])),
              sorted(kwargs.items()),
          )
      )
      self._ub = np.array(
          map(
              lambda x: float(x[1][1] - delta * (x[1][1] - x[1][0])),
              sorted(kwargs.items()),
          )
      )
  
file_path: optunity/optunity/solvers/BayesOpt.py
imports: from .solver_registry import register_solver
  from .util import Solver, _copydoc
  import functools
  import random
label_desc: Use image node_id 1 to create a new BayesOpt object from inherited base classes: Solver with example: obj = BayesOpt(num_evals, seed)