[docs]classHPOptimizationStrategy(metaclass=abc.ABCMeta):""" hyper-parameter optimization strategy is a base class of all different hyper-parameter optimization approaches, such as grid search, random search, bayesian optimization etc. HPOptimizationStrategy internally keeps a dict of settings that were tried out and the metric value that was obtained on the validation set which it then uses to determine the next step """def__init__(self,hp_settings:list,search_criterion=max):self.hp_settings={hp_setting.get_key():hp_settingforhp_settinginhp_settings}self.search_space_metric={hp_setting.get_key():Noneforhp_settinginhp_settings}self.search_criterion=search_criterion
[docs]@abc.abstractmethoddefgenerate_next_setting(self,hp_setting:HPSetting=None,metric:dict=None):""" generator function which returns the next hyper-parameter setting to be evaluated :param hp_setting: previous setting (None if it's the first iteration) :param metric: performance metric from the previous setting per label :return: new hp_setting or None (if the end is reached) """pass