docstr: Fits for each given budget a kernel density estimator on the best N percent of the
  evaluated configurations on this budget.
  
  
  Parameters:
  -----------
  configspace: ConfigSpace
          Configuration space object
  top_n_percent: int
          Determines the percentile of configurations that will be used as training data
          for the kernel density estimator, e.g if set to 10 the 10% best configurations will be considered
          for training.
  min_points_in_model: int
          minimum number of datapoints needed to fit a model
  num_samples: int
          number of samples drawn to optimize EI via sampling
  random_fraction: float
          fraction of random configurations returned
  bw_estimator: string
          how the bandwidths is estimated. Possible values are 'scott' and 'mlcv' for maximum likelihood estimation
  min_bandwidth: float
          to keep diversity, even when all (good) samples have the same value for one of the parameters,
          a minimum bandwidth (Default: 1e-3) is used instead of zero. 
  fully_dimensional: bool
          if true, the KDE is uses factored kernel across all dimensions, otherwise the PDF is a product of 1d PDFs
docstr_tok: ["Fits","for","each","given","budget","a","kernel","density","estimator","on","the","best","N","percent","of","the","evaluated","configurations","on","this","budget",".","Parameters",":","--","--","--","--","--","-","configspace",":","ConfigSpace","Configuration","space","object","top_n_percent",":","int","Determines","the","percentile","of","configurations","that","will","be","used","as","training","data","for","the","kernel","density","estimator",",","e.g","if","set","to","10","the","10","%","best","configurations","will","be","considered","for","training",".","min_points_in_model",":","int","minimum","number","of","datapoints","needed","to","fit","a","model","num_samples",":","int","number","of","samples","drawn","to","optimize","EI","via","sampling","random_fraction",":","float","fraction","of","random","configurations","returned","bw_estimator",":","string","how","the","bandwidths","is","estimated",".","Possible","values","are","'scott","'","and","'mlcv","'","for","maximum","likelihood","estimation","min_bandwidth",":","float","to","keep","diversity",",","even","when","all","(","good",")","samples","have","the","same","value","for","one","of","the","parameters",",","a","minimum","bandwidth","(","Default",":","1e-3",")","is","used","instead","of","zero",".","fully_dimensional",":","bool","if","true",",","the","KDE","is","uses","factored","kernel","across","all","dimensions",",","otherwise","the","PDF","is","a","product","of","1d","PDFs"]
code: def __init__(
      self,
      configspace,
      min_points_in_model=None,
      top_n_percent=15,
      num_samples=64,
      random_fraction=1 / 3,
      min_bandwidth=1e-3,
      bw_estimator="scott",
      fully_dimensional=True,
      **kwargs,
  ):
      """
      Fits for each given budget a kernel density estimator on the best N percent of the
      evaluated configurations on this budget.
  
  
      Parameters:
      -----------
      configspace: ConfigSpace
              Configuration space object
      top_n_percent: int
              Determines the percentile of configurations that will be used as training data
              for the kernel density estimator, e.g if set to 10 the 10% best configurations will be considered
              for training.
      min_points_in_model: int
              minimum number of datapoints needed to fit a model
      num_samples: int
              number of samples drawn to optimize EI via sampling
      random_fraction: float
              fraction of random configurations returned
      bw_estimator: string
              how the bandwidths is estimated. Possible values are 'scott' and 'mlcv' for maximum likelihood estimation
      min_bandwidth: float
              to keep diversity, even when all (good) samples have the same value for one of the parameters,
              a minimum bandwidth (Default: 1e-3) is used instead of zero.
      fully_dimensional: bool
              if true, the KDE is uses factored kernel across all dimensions, otherwise the PDF is a product of 1d PDFs
  
      """
      super().__init__(**kwargs)
      self.top_n_percent = top_n_percent
      self.configspace = configspace
      self.bw_estimator = bw_estimator
      self.min_bandwidth = min_bandwidth
      self.fully_dimensional = fully_dimensional
  
      self.min_points_in_model = min_points_in_model
      if min_points_in_model is None:
          self.min_points_in_model = (
              len(self.configspace.get_hyperparameters()) + 1
          )
  
      # if self.min_points_in_model < len(self.configspace.get_hyperparameters())+1:
      # 	self.logger.warning('Invalid min_points_in_model value. Setting it to %i'%(len(self.configspace.get_hyperparameters())+1))
      # 	self.min_points_in_model =len(self.configspace.get_hyperparameters())+1
  
      self.num_samples = num_samples
      self.random_fraction = random_fraction
  
      self.configs = dict()
      self.losses = dict()
      self.good_config_rankings = dict()
      self.kde_models = dict()
  
file_path: auptimizer/src/aup/Proposer/hpbandster/optimizers/config_generators/h2bo.py
imports: import logging
  from copy import deepcopy
  import traceback
  import ConfigSpace
  import ConfigSpace.hyperparameters
  import ConfigSpace.util
  import numpy
  import scipy.stats
  from hpbandster.core.base_config_generator import base_config_generator
  from hpbandster.optimizers.kde.mvkde import MultivariateKDE
label_desc: Use image node_id 1 to create a new H2BO object from inherited base classes: base_config_generator with example: obj = H2BO(configspace, min_points_in_model, top_n_percent, num_samples, random_fraction, min_bandwidth, bw_estimator, fully_dimensional)