mlrl.testbed.experiments.state module

Author: Michael Rapp (michael.rapp.ml@gmail.com)

Provides classes for representing the state of experiments.

class mlrl.testbed.experiments.state.ExperimentMode(*values)

Bases: StrEnum

Represents the mode of operation.

BATCH = 'batch'
READ = 'read'
RUN = 'run'
SINGLE = 'single'
class mlrl.testbed.experiments.state.ExperimentState(mode: ExperimentMode, args: Namespace, meta_data: MetaData, problem_domain: ProblemDomain, folding_strategy: FoldingStrategy | None = None, dataset_type: DatasetType = DatasetType.TRAINING, dataset: Any | None = None, fold: Fold | None = None, parameters: dict[str, ~typing.Any]=<factory>, training_result: TrainingState | None = None, prediction_result: PredictionState | None = None, extras: dict[str, ~typing.Any]=<factory>)

Bases: object

Represents the state of an experiment.

Attributes:

mode: The mode of operation args: The command line argument that have been used to start the experiment meta_data: Meta-data about the command that has been used for running the experiment problem_domain: The problem domain, the experiment is concerned with folding_strategy: The strategy that is used for creating different folds of the dataset during the experiment dataset_type: The type of the dataset used in the experiment dataset: The dataset used in the experiment or None, if no dataset has been loaded yet fold: The current fold of the dataset or None, if the state does not correspond to a specific fold parameters: Algorithmic parameters of the learner used in the experiment training_result: The result of the training process or None, if no model has been trained yet prediction_result: The result of the prediction process or None, if no predictions have been obtained yet extras: A dictionary that can be used to store arbitrary data referenced via a unique key

args: Namespace
dataset: Any | None = None
dataset_as(*types: type[Any]) Any | None

Returns the dataset used in the experiment, if it has one of given types. Otherwise, a log message is omitted and None is returned.

Parameters:

types – The accepted types

Returns:

The dataset or None, if it does not have the correct type

dataset_type: DatasetType = 'training'
extras: dict[str, Any]
fold: Fold | None = None
folding_strategy: FoldingStrategy | None = None
learner_as(*types: type[Any]) Any | None

Returns the learner that has been trained in the experiment, if it has one of given types. Otherwise, a log message is omitted and None is returned.

Parameters:

types – The accepted types

Returns:

The learner or None, if it does not have the correct type

meta_data: MetaData
mode: ExperimentMode
parameters: dict[str, Any]
prediction_result: PredictionState | None = None
problem_domain: ProblemDomain
training_result: TrainingState | None = None
class mlrl.testbed.experiments.state.PredictionResult(predictions: Any, prediction_type: PredictionType, prediction_duration: Duration)

Bases: object

Stores the result of a prediction process.

Attributes:

predictions: A numpy.ndarray, scipy.sparse.spmatrix or scipy.sparse.sparray storing predictions prediction_type: The type of the predictions prediction_duration: The time needed for prediction

prediction_duration: Duration
prediction_type: PredictionType
predictions: Any
class mlrl.testbed.experiments.state.PredictionState(prediction_scope: PredictionScope, prediction_result: PredictionResult | None = None)

Bases: object

Represents the result of a prediction process.

Attributes:

prediction_scope: Whether the predictions have been obtained from a global model or incrementally prediction_result: The result of the prediction process, if available

prediction_result: PredictionResult | None = None
prediction_scope: PredictionScope
class mlrl.testbed.experiments.state.TrainingState(learner: Any, training_duration: Duration = <factory>)

Bases: object

Represents the result of a training process.

Attributes:

learner: The learner that has been trained training_duration: The time needed for training

learner: Any
training_duration: Duration