rekall.tuner.tuner module¶
This module defines the Tuner
class, which all Rekall auto-tuners should
inherit from.
-
class
rekall.tuner.tuner.
Tuner
(search_space, eval_fn, maximize=True, budget=500, log=False, log_dir=None, run_dir=None, run_name=None, start_config=None, start_score=None, score_fn=<function Tuner.<lambda>>, score_log_fn=<function Tuner.<lambda>>, num_workers=1, show_loading=True)¶ Bases:
object
Base class for all Tuners (see sub-classes for details).
Parameters: - search_space (dict) – A dictionary of parameters to search over. See note below for more details.
- eval_fn – Given a configuration, evaluate the black box function and return the score.
- maximize (bool) – Maximize the output of
eval_fn
if True, otherwise minimize it. - budget (int) – Maximum number of times to call the evaluation function.
- log (bool) – Whether to log results
- log_dir (string) – Directory to log all results to
- run_dir (string) – Directory to log results from a set of runs
- run_name (string) – Name of this run
- start_config (dict) – Some tuners ask for a starting configuration. If start_config is specified, start with this config.
- start_score (float) – If start_config is specified, you can also specify its score if you know it ahead of time.
- score_fn – Your eval function may not return exactly the value you want to optimize. This function parses the output of eval_fn to pass to the optimizer.
- score_log_fn – Your eval function may not return exactly what you want to log. This function parses the output of eval_fn to log.
- num_workers (int) – Number of workers for parallelism. See sub-classes to check whether supported. Default 1.
- show_loading (bool) – Whether to show a loading bar (not always supported).
Example:
def eval_config(params): # Run the Rekall query query_results = rekall_query( param1 = params['param1'], param2 = params['param2']) # Evaluate the results score = evaluate(query_results) return score search_space = { 'param1': [0.0, 1.0, 2.0], # discrete 'param2': { 'range': (10.0, 20.0) } # linear range } tuner = RandomTuner(search_space, eval_config, budget = 50) best_score, best_config, score_history, execution_times, total_cost = tuner.tune()
-
evaluate_configs
(configs, num_workers=None, show_loading=None)¶ Evaluate the configs.
-
log_msg
(msg)¶ Log something to the log file.
-
tune
(**kwargs)¶ Run the tuning algorithm!
-
tune_impl
(**kwargs)¶ The implementation of the tuning algorithm.
Sub-classes should implement this!