mlrl.testbed.modes package¶
Author Michael Rapp (michael.rapp.ml@gmail.com)
Provides classes for implementing different modes of operation.
- class mlrl.testbed.modes.BatchMode(config_file_factory: Callable[[str], ConfigFile] | None = None)¶
Bases:
ModeAn abstract base class for all modes of operation that perform multiple experiments.
- ARGUMENT_RUNNER = '--runner'¶
- CONFIG_FILE = <mlrl.util.cli.PathArgument object>¶
- class ConfigFile(file_path: Path, schema_file_path: Path)¶
Bases:
ABCA YAML configuration file that configures the batch of experiments to be run.
- class DefaultArgument(name: str, value: str)¶
Bases:
objectA default parameter defined in the configuration file.
- Attributes:
name: The name of the parameter value: The value of the parameter
- Factory¶
alias of
Callable[[str],BatchMode.ConfigFile]
- class Parameter(name: str, values: list[ParameterValue])¶
Bases:
objectA parameter defined in the configuration file.
- Attributes:
name: The name of the parameter values: One or several values that should be set for the parameter
- values: list[ParameterValue]¶
- class ParameterValue(value: str, additional_arguments: list[str] = <factory>)¶
Bases:
objectA value that should be set for a parameter.
- Attributes:
value: The value to be set additional_arguments: Additional arguments associated with the parameter
- abstract property dataset_args: list[ArgumentList]¶
A list that contains the command line arguments corresponding to the datasets to be used in the different experiments defined in the configuration file.
- property default_arguments: list[DefaultArgument]¶
A list that contains all default arguments defined in the configuration file.
- property parameter_args: list[ArgumentList]¶
A list that contains the command line arguments corresponding to the algorithmic parameters to be used in the different experiments defined in the configuration file.
- LIST_COMMANDS = <mlrl.util.cli.FlagArgument object>¶
- class LogRunner¶
Bases:
RunnerAllows to log the commands of experiments, instead of executing them.
- run_batch(args: Namespace, batch: list[Command], recipe: Recipe)¶
Must be implemented by subclasses in order to run all commands in a given batch.
- Parameters:
args – The command line arguments specified by the user
batch – The batch of experiments to be run
recipe – A Recipe that provides access to the ingredients that are needed for setting up experiments
- class Runner(name: str)¶
Bases:
ABCAn abstract base class for all classes that allow to run experiments.
- abstractmethod run_batch(args: Namespace, batch: list[Command], recipe: Recipe)¶
Must be implemented by subclasses in order to run all commands in a given batch.
- Parameters:
args – The command line arguments specified by the user
batch – The batch of experiments to be run
recipe – A Recipe that provides access to the ingredients that are needed for setting up experiments
- SEPARATE_FOLDS = <mlrl.util.cli.BoolArgument object>¶
- class SequentialRunner¶
Bases:
RunnerAllows to run experiments sequentially.
- run_batch(args: Namespace, batch: list[Command], recipe: Recipe)¶
Must be implemented by subclasses in order to run all commands in a given batch.
- Parameters:
args – The command line arguments specified by the user
batch – The batch of experiments to be run
recipe – A Recipe that provides access to the ingredients that are needed for setting up experiments
- add_runner(runner: Runner) BatchMode¶
Adds a runner that may be used in batch mode for running individual experiments in a batch.
- Parameters:
runner – The runner to be added
- Returns:
The batch mode itself
- configure_algorithmic_arguments(cli: CommandLineInterface, algorithmic_arguments: list[Argument])¶
Must be implemented by subclasses in order to configure the command line interface according to the mode of operation.
- Parameters:
cli – The command line interface to be configured
algorithmic_arguments – The arguments that should be added to the command line interface for configuring the algorithm’s hyperparameters
- configure_control_arguments(cli: CommandLineInterface, control_arguments: list[Argument])¶
Must be implemented by subclasses in order to configure the command line interface according to the mode of operation.
- Parameters:
cli – The command line interface to be configured
control_arguments – The arguments that should be added to the command line interface for controlling mlrl-testbed’s behavior
- run_experiment(control_arguments: set[Argument], algorithmic_arguments: set[Argument], args: Namespace, recipe: Recipe)¶
Must be implemented by subclasses in order to run an experiment according to the command line arguments specified by the user.
- Parameters:
control_arguments – The arguments that should be added to the command line interface for controlling mlrl-testbed’s behavior
algorithmic_arguments – The arguments that should be added to the command line interface for configuring the algorithm’s hyperparameters
args – The command line arguments specified by the user
recipe – A Recipe that provides access to the ingredients that are needed for setting up experiments
- property runners: list[Runner]¶
The runners that may be used for running individual experiments in a batch.
- to_enum() ExperimentMode¶
Returns the ExperimentMode that corresponds to this mode of operation.
- Returns:
An ExperimentMode
- class mlrl.testbed.modes.Mode¶
Bases:
ABCAn abstract base class for all modes of operation.
- MODE = <mlrl.util.cli.SetArgument object>¶
- abstractmethod configure_algorithmic_arguments(cli: CommandLineInterface, algorithmic_arguments: list[Argument])¶
Must be implemented by subclasses in order to configure the command line interface according to the mode of operation.
- Parameters:
cli – The command line interface to be configured
algorithmic_arguments – The arguments that should be added to the command line interface for configuring the algorithm’s hyperparameters
- abstractmethod configure_control_arguments(cli: CommandLineInterface, control_arguments: list[Argument])¶
Must be implemented by subclasses in order to configure the command line interface according to the mode of operation.
- Parameters:
cli – The command line interface to be configured
control_arguments – The arguments that should be added to the command line interface for controlling mlrl-testbed’s behavior
- abstractmethod run_experiment(control_arguments: set[Argument], algorithmic_arguments: set[Argument], args: Namespace, recipe: Recipe)¶
Must be implemented by subclasses in order to run an experiment according to the command line arguments specified by the user.
- Parameters:
control_arguments – The arguments that should be added to the command line interface for controlling mlrl-testbed’s behavior
algorithmic_arguments – The arguments that should be added to the command line interface for configuring the algorithm’s hyperparameters
args – The command line arguments specified by the user
recipe – A Recipe that provides access to the ingredients that are needed for setting up experiments
- abstractmethod to_enum() ExperimentMode¶
Returns the ExperimentMode that corresponds to this mode of operation.
- Returns:
An ExperimentMode
- class mlrl.testbed.modes.ReadMode¶
Bases:
InputModeAn abstract base class for all modes of operation that read experimental results.
- class AggregateEvaluationProcedure(evaluation_by_dataset_type: dict[DatasetType, dict[str, Table]])¶
Bases:
ExperimentalProcedureThe procedure that is used to write evaluation results that have been aggregated across several experiments to one or several sinks.
- to_enum() ExperimentMode¶
Returns the ExperimentMode that corresponds to this mode of operation.
- Returns:
An ExperimentMode
- class mlrl.testbed.modes.RunMode¶
Bases:
InputModeAn abstract base class for all modes of operation for re-running experiments based on their meta-data.
- to_enum() ExperimentMode¶
Returns the ExperimentMode that corresponds to this mode of operation.
- Returns:
An ExperimentMode
- class mlrl.testbed.modes.SingleMode¶
Bases:
ModeA mode of operation that performs a single experiment.
- configure_algorithmic_arguments(cli: CommandLineInterface, algorithmic_arguments: list[Argument])¶
Must be implemented by subclasses in order to configure the command line interface according to the mode of operation.
- Parameters:
cli – The command line interface to be configured
algorithmic_arguments – The arguments that should be added to the command line interface for configuring the algorithm’s hyperparameters
- configure_control_arguments(cli: CommandLineInterface, control_arguments: list[Argument])¶
Must be implemented by subclasses in order to configure the command line interface according to the mode of operation.
- Parameters:
cli – The command line interface to be configured
control_arguments – The arguments that should be added to the command line interface for controlling mlrl-testbed’s behavior
- run_experiment(control_arguments: set[Argument], algorithmic_arguments: set[Argument], args: Namespace, recipe: Recipe)¶
Must be implemented by subclasses in order to run an experiment according to the command line arguments specified by the user.
- Parameters:
control_arguments – The arguments that should be added to the command line interface for controlling mlrl-testbed’s behavior
algorithmic_arguments – The arguments that should be added to the command line interface for configuring the algorithm’s hyperparameters
args – The command line arguments specified by the user
recipe – A Recipe that provides access to the ingredients that are needed for setting up experiments
- to_enum() ExperimentMode¶
Returns the ExperimentMode that corresponds to this mode of operation.
- Returns:
An ExperimentMode
Submodules¶
- mlrl.testbed.modes.mode module
- mlrl.testbed.modes.mode_batch module
BatchModeBatchMode.ARGUMENT_RUNNERBatchMode.CONFIG_FILEBatchMode.ConfigFileBatchMode.LIST_COMMANDSBatchMode.LogRunnerBatchMode.RunnerBatchMode.SEPARATE_FOLDSBatchMode.SequentialRunnerBatchMode.add_runner()BatchMode.configure_algorithmic_arguments()BatchMode.configure_control_arguments()BatchMode.run_experiment()BatchMode.runnersBatchMode.runners_BatchMode.to_enum()
- mlrl.testbed.modes.mode_read module
- mlrl.testbed.modes.mode_run module
- mlrl.testbed.modes.mode_single module
- mlrl.testbed.modes.util module