autoflow.tuner package¶
Submodules¶
autoflow.tuner module¶
-
class
autoflow.tuner.
Tuner
(evaluator: Union[Callable, str] = 'TrainEvaluator', search_method: str = 'smac', run_limit: int = 100, initial_runs: int = 20, search_method_params: dict = <frozendict {}>, n_jobs: int = 1, exit_processes: Optional[int] = None, limit_resource: bool = True, per_run_time_limit: float = 60, per_run_memory_limit: float = 3072, time_left_for_this_task: float = None, n_jobs_in_algorithm=1, debug=False)[source]¶ Bases:
autoflow.utils.klass.StrSignatureMixin
Tuner
if class who agent an abstract search process.- Parameters
evaluator (callable, str) –
evaluator
is a function or callable class (implement magic method__call__
) or string-indicator.evaluator
can receive a shp(SMAC Hyper Param,ConfigSpace.ConfigurationSpace
),and return a dict ,which contains such keys:
loss
, you can think of it as negative reward.status
, a string ,SUCCESS
means fine,FAILED
means crashed.
As default, “TrainEvaluator” is the string-indicator of
autoflow.evaluation.train_evaluator.TrainEvaluator
.search_method (str) –
Specific searching method,
random
,smac
,grid
are available.random
Random Search Algorithm,grid
Grid Search Algorithm,smac
Bayes Search by SMAC Algorithm.
run_limit (int) – Limitation of running step.
initial_runs (int) –
If you choose
smac
algorithm,you should realize the SMAC algorithm has a initialize procedure,
The algorithm needs enough initial runs to get enough experience.
This param will be omitted if
random
orgrid
is selected.search_method_params (dict) – Configuration for specific search method.
n_jobs (int) –
n_jobs
searching process will start.exit_processes (int) –
limit_resource (bool) – If
limit_resource = True
, a searching trial will be killed if it use more CPU times or memory.per_run_time_limit (float) –
will active if
limit_resource = True
.a searching trial will be killed if it use CPU times more than
per_run_time_limit
.per_run_memory_limit (float) –
will active if
limit_resource = True
.a searching trial will be killed if it use memory more than
per_run_memory_limit
.time_left_for_this_task (float) –
will active if
limit_resource = True
.a searching task will be killed if it’s totally run time more than
time_left_for_this_task
.debug (bool) –
For debug mode.
Exception will be re-raised if
debug = True
-
match_cs_key
(step_name: str, config: Union[ConfigSpace.configuration_space.Configuration, ConfigSpace.configuration_space.ConfigurationSpace])[source]¶
-
prepare_beam_search_configs
(config_space: ConfigSpace.configuration_space.ConfigurationSpace, cs_keys: List[str], search_ranges: List[List[Any]])[source]¶
-
run
(initial_configs, evaluator_params=<frozendict {}>, instance_id='', rh_db_type='sqlite', rh_db_params=<frozendict {}>, rh_db_table_name='runhistory')[source]¶
-
set_beam_search_result_to_cs_default
(config_space: ConfigSpace.configuration_space.ConfigurationSpace, beam_result: dict)[source]¶
-
set_task
(ml_task: autoflow.utils.ml_task.MLTask)[source]¶
Module contents¶
-
class
autoflow.tuner.
Tuner
(evaluator: Union[Callable, str] = 'TrainEvaluator', search_method: str = 'smac', run_limit: int = 100, initial_runs: int = 20, search_method_params: dict = <frozendict {}>, n_jobs: int = 1, exit_processes: Optional[int] = None, limit_resource: bool = True, per_run_time_limit: float = 60, per_run_memory_limit: float = 3072, time_left_for_this_task: float = None, n_jobs_in_algorithm=1, debug=False)[source]¶ Bases:
autoflow.utils.klass.StrSignatureMixin
Tuner
if class who agent an abstract search process.- Parameters
evaluator (callable, str) –
evaluator
is a function or callable class (implement magic method__call__
) or string-indicator.evaluator
can receive a shp(SMAC Hyper Param,ConfigSpace.ConfigurationSpace
),and return a dict ,which contains such keys:
loss
, you can think of it as negative reward.status
, a string ,SUCCESS
means fine,FAILED
means crashed.
As default, “TrainEvaluator” is the string-indicator of
autoflow.evaluation.train_evaluator.TrainEvaluator
.search_method (str) –
Specific searching method,
random
,smac
,grid
are available.random
Random Search Algorithm,grid
Grid Search Algorithm,smac
Bayes Search by SMAC Algorithm.
run_limit (int) – Limitation of running step.
initial_runs (int) –
If you choose
smac
algorithm,you should realize the SMAC algorithm has a initialize procedure,
The algorithm needs enough initial runs to get enough experience.
This param will be omitted if
random
orgrid
is selected.search_method_params (dict) – Configuration for specific search method.
n_jobs (int) –
n_jobs
searching process will start.exit_processes (int) –
limit_resource (bool) – If
limit_resource = True
, a searching trial will be killed if it use more CPU times or memory.per_run_time_limit (float) –
will active if
limit_resource = True
.a searching trial will be killed if it use CPU times more than
per_run_time_limit
.per_run_memory_limit (float) –
will active if
limit_resource = True
.a searching trial will be killed if it use memory more than
per_run_memory_limit
.time_left_for_this_task (float) –
will active if
limit_resource = True
.a searching task will be killed if it’s totally run time more than
time_left_for_this_task
.debug (bool) –
For debug mode.
Exception will be re-raised if
debug = True
-
match_cs_key
(step_name: str, config: Union[ConfigSpace.configuration_space.Configuration, ConfigSpace.configuration_space.ConfigurationSpace])[source]¶
-
prepare_beam_search_configs
(config_space: ConfigSpace.configuration_space.ConfigurationSpace, cs_keys: List[str], search_ranges: List[List[Any]])[source]¶
-
run
(initial_configs, evaluator_params=<frozendict {}>, instance_id='', rh_db_type='sqlite', rh_db_params=<frozendict {}>, rh_db_table_name='runhistory')[source]¶
-
set_beam_search_result_to_cs_default
(config_space: ConfigSpace.configuration_space.ConfigurationSpace, beam_result: dict)[source]¶
-
set_task
(ml_task: autoflow.utils.ml_task.MLTask)[source]¶