class_docstr: Holds the param-space coordinates (X) and target values (Y)
  Allows for constant-time appends while ensuring no duplicates are added
  
  Example
  -------
  >>> def target_func(p1, p2):
  >>>     return p1 + p2
  >>> pbounds = {'p1': (0, 1), 'p2': (1, 100)}
  >>> space = TargetSpace(target_func, pbounds, random_state=0)
  >>> x = np.array([4 , 5])
  >>> y = target_func(x)
  >>> space.register(x, y)
  >>> assert self.max()['target'] == 9
  >>> assert self.max()['params'] == {'p1': 1.0, 'p2': 2.0}
class_docstr_tok: ["Holds","the","param-space","coordinates","(","X",")","and","target","values","(","Y",")","Allows","for","constant-time","appends","while","ensuring","no","duplicates","are","added","Example","--","--","--","-",">",">",">","def","target_func","(","p1",",","p2",")",":",">",">",">","return","p1","+","p2",">",">",">","pbounds","=","{","'p1","'",":","(","0",",","1",")",",","'p2","'",":","(","1",",","100",")","}",">",">",">","space","=","TargetSpace","(","target_func",",","pbounds",",","random_state=0",")",">",">",">","x","=","np.array","(","[","4",",","5","]",")",">",">",">","y","=","target_func","(","x",")",">",">",">","space.register","(","x",",","y",")",">",">",">","assert","self.max","(",")","[","'target","'","]","==","9",">",">",">","assert","self.max","(",")","[","'params","'","]","==","{","'p1","'",":","1.0",",","'p2","'",":","2.0","}"]
docstr: Parameters
  ----------
  target_func : function
      Function to be maximized.
  
  pbounds : dict
      Dictionary with parameters names as keys and a tuple with minimum
      and maximum values.
  
  random_state : int, RandomState, or None
      optionally specify a seed for a random number generator
  
  allow_duplicate_points: bool, optional (default=False)
      If True, the optimizer will allow duplicate points to be registered.
      This behavior may be desired in high noise situations where repeatedly probing
      the same point will give different answers. In other situations, the acquisition
      may occasionally generate a duplicate point.
docstr_tok: ["Parameters","--","--","--","--","--","target_func",":","function","Function","to","be","maximized",".","pbounds",":","dict","Dictionary","with","parameters","names","as","keys","and","a","tuple","with","minimum","and","maximum","values",".","random_state",":","int",",","RandomState",",","or","None","optionally","specify","a","seed","for","a","random","number","generator","allow_duplicate_points",":","bool",",","optional","(","default=False",")","If","True",",","the","optimizer","will","allow","duplicate","points","to","be","registered",".","This","behavior","may","be","desired","in","high","noise","situations","where","repeatedly","probing","the","same","point","will","give","different","answers",".","In","other","situations",",","the","acquisition","may","occasionally","generate","a","duplicate","point","."]
code: def __init__(
      self,
      target_func,
      pbounds,
      constraint=None,
      random_state=None,
      allow_duplicate_points=False,
  ):
      """
      Parameters
      ----------
      target_func : function
          Function to be maximized.
  
      pbounds : dict
          Dictionary with parameters names as keys and a tuple with minimum
          and maximum values.
  
      random_state : int, RandomState, or None
          optionally specify a seed for a random number generator
  
      allow_duplicate_points: bool, optional (default=False)
          If True, the optimizer will allow duplicate points to be registered.
          This behavior may be desired in high noise situations where repeatedly probing
          the same point will give different answers. In other situations, the acquisition
          may occasionally generate a duplicate point.
      """
      self.random_state = ensure_rng(random_state)
      self._allow_duplicate_points = allow_duplicate_points
      self.n_duplicate_points = 0
  
      # The function to be optimized
      self.target_func = target_func
  
      # Get the name of the parameters
      self._keys = sorted(pbounds)
      # Create an array with parameters bounds
      self._bounds = np.array(
          [
              item[1]
              for item in sorted(pbounds.items(), key=lambda x: x[0])
          ],
          dtype=float,
      )
  
      # preallocated memory for X and Y points
      self._params = np.empty(shape=(0, self.dim))
      self._target = np.empty(shape=(0))
  
      # keep track of unique points we have seen so far
      self._cache = {}
  
      self._constraint = constraint
  
      if constraint is not None:
          # preallocated memory for constraint fulfillment
          if constraint.lb.size == 1:
              self._constraint_values = np.empty(shape=(0), dtype=float)
          else:
              self._constraint_values = np.empty(
                  shape=(0, constraint.lb.size), dtype=float
              )
  
imports: import numpy
  from warnings import warn
  from .util import ensure_rng, NotUniqueError
  from .util import Colours
label_desc: Use image node_id 1 to create a new TargetSpace object from inherited base classes: object with example: obj = TargetSpace(target_func, pbounds, constraint, random_state, allow_duplicate_points)