Saving and Loading ParametersΒΆ
To remember the parameters that have been used for training a model, it might be useful to save them to disk. Similar to saving models, keeping the resulting files allows to load a previously used configuration and reuse it at a later point in time.
This requires to specify a directory via the command line argument --parameter-save-dir, where parameters set via the command line API (see Setting Algorithmic Parameters) should be saved. For example, the following command sets a custom value for a parameter, which is stored in an output file:
mlrl-testbed mlrl.boosting \
--data-dir /path/to/datasets/ \
--dataset dataset-name \
--parameter-save-dir /path/to/parameters \
--shrinkage 0.5
mlrl-testbed mlrl.seco \
--data-dir /path/to/datasets/ \
--dataset dataset-name \
--parameter-save-dir /path/to/parameters \
--heuristic precision
If train-test splits are used for splitting the available data into training and test sets, a single model is trained and its configuration is saved to a file:
parameters.csv
If a cross validation is performed instead, one model is trained per cross validation fold and the configurations of all of these models are stored in the specified directory. For example, a 5-fold cross validation results in the following files:
parameters_fold-1.csvparameters_fold-2.csvparameters_fold-3.csvparameters_fold-4.csvparameters_fold-5.csv
Note
Only parameters with custom values are included in the output files. Parameters for which the default value is used are not included.
If you want to print all custom parameters that are used by a learning algorithm on the console, you can specify the argument --print-parameters true:
mlrl-testbed mlrl.boosting \
--data-dir /path/to/datasets/ \
--dataset dataset-name \
--print-parameters true \
--shrinkage 0.5
mlrl-testbed mlrl.seco \
--data-dir /path/to/datasets/ \
--dataset dataset-name \
--print-parameters true \
--heuristic precision
Once parameters have been saved to a directory, they can be loaded in subsequent experiments by specifying the command line argument --parameter-load-dir. This allows to omit the respective parameters from the command line. If a parameter is included in both, the loaded file and the command line arguments, the latter takes precedence.
mlrl-testbed mlrl.boosting \
--data-dir /path/to/datasets/ \
--dataset dataset-name \
--parameter-load-dir /path/to/parameters \
mlrl-testbed mlrl.seco \
--data-dir /path/to/datasets/ \
--dataset dataset-name \
--parameter-load-dir /path/to/parameters \
Note
The paths of the directories that are specified via the arguments --parameter-save-dir and --parameter-load-dir can be either absolute or relative to the working directory.