Skip to main content
Version: v2509

tuners.command_output

CommandOutputTuner Objects

class CommandOutputTuner(GeneralTuner)

A tuner for executing commands and extracting values.

__init__

def __init__(output_dir: str = "outputs",
study_name: Optional[str] = None,
db_path: Optional[str] = None,
sampler: Optional[BaseSampler] = None,
pruner: Optional[BasePruner] = None,
auto_pruners: Optional[List[AutoPrunerBase]] = None,
maximize: bool = False) -> None

Initialize the CommandOutputTuner.

Arguments:

  • output_dir str - The directory to store the study results. Defaults to "outputs".
  • study_name str - The name of the study. Defaults to None.
  • db_path Optional[str] - The path to the database file. Defaults to None.
  • sampler Optional[BaseSampler] - The sampler to use. Defaults to None.
  • pruner Optional[BasePruner] - The pruner to use. Defaults to None.
  • auto_pruners Optional[List[AutoPrunerBase]] - List of auto pruners to monitor during execution. Defaults to None.
  • maximize bool - Whether to maximize the objective function. Defaults to False.

optimize

def optimize(
command_generator: Callable[..., str],
value_extractor: Callable[[str], Optional[float]],
n_trials: int,
default_params: Optional[Dict[str, Any]] = None
) -> Tuple[float, Dict[str, Any]]

Optimize the given objective function using Optuna.

Arguments:

  • command_generator Callable[..., str] - A function that generates the command to execute.
  • value_extractor Callable[[str], Optional[float]] - A function that extracts the value from the log file.
  • n_trials int - The number of trials to run.
  • default_params Optional[Dict[str, Any]] - Default parameters to use for the optimization.

Returns:

Tuple[float, Dict[str, Any]]: The best value and parameters found during optimization.