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.ExperimentState(meta_data: ~mlrl.testbed.experiments.meta_data.MetaData, problem_domain: ~mlrl.testbed.experiments.problem_domain.ProblemDomain, folding_strategy: ~mlrl.testbed.experiments.fold.FoldingStrategy | None = None, dataset_type: ~mlrl.testbed.experiments.dataset_type.DatasetType = DatasetType.TRAINING, dataset: ~typing.Any | None = None, fold: ~mlrl.testbed.experiments.fold.Fold | None = None, parameters: ~typing.Dict[str, ~typing.Any] = <factory>, training_result: ~mlrl.testbed.experiments.state.TrainingState | None = None, prediction_result: ~mlrl.testbed.experiments.state.PredictionState | None = None)

Bases: object

Represents the state of an experiment.

Attributes:

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

dataset: Any | None = None
dataset_as(caller: Any, *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:
  • caller – The caller of this function to be included in the log message

  • types – The accepted types

Returns:

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

dataset_type: DatasetType = 'training'
fold: Fold | None = None
folding_strategy: FoldingStrategy | None = None
learner_as(caller: Any, *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:
  • caller – The caller of this function to be included in the log message

  • types – The accepted types

Returns:

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

meta_data: MetaData
parameters: Dict[str, Any]
prediction_result: PredictionState | None = None
problem_domain: ProblemDomain
training_result: TrainingState | None = None
class mlrl.testbed.experiments.state.PredictionState(predictions: Any, prediction_type: PredictionType, prediction_scope: PredictionScope, 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_scope: Whether the predictions have been obtained from a global model or incrementally prediction_duration: The time needed for prediction

prediction_duration: Duration
prediction_scope: PredictionScope
prediction_type: PredictionType
predictions: Any
class mlrl.testbed.experiments.state.TrainingState(learner: ~typing.Any, training_duration: ~mlrl.testbed.experiments.timer.Timer.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