xesn.Driver.run_macro_training

xesn.Driver.run_macro_training#

Driver.run_macro_training()#

Perform Bayesian optimization on macro-scale ESN parameters using surrogate modeling toolbox. Resulting optimized parameters are written to config-optim.yaml and to the log file stdout.log in the output_directory

Required Parameter Sections:
  • xdata – all options are used to create an XData object. If subsampling is provided, it must have slicing options labelled “training” and “macro_training”.

  • esn or lazyesn – all options are used to create a ESN or LazyESN object, depending on the name of the section, case does not matter

  • training – all options are passed to ESN.train() or LazyESN.train()

  • macro_training – with the following subsections

    • “parameters” (required): with key/value pairs as the parameters to be optimized, and their bounds as values

    • “transformations” (optional): with any desired transformations on the input variables pre-optimization, see xesn.optim.transform() for example

    • “forecast” (required): with options for sample forecasts to optimize macro parameters with, see get_samples() for a list of parameters (other than xda)

    • “ego” (required): with parameters except for evaluation/cost function (which is defined by a CostFunction) and surrogate (assumed to be smt.surrogate_models.KRG) as passed to smt.applications.EGO

    • “cost_terms” (optional): forms the cost function defined in CostFunction by determining the weights for the NRMSE and PSD_NRMSE cost terms (default: {"nrmse": 1})

    • “cost_upper_bound” (optional): remove sensitivity to values larger than this number by setting all numpy.inf, numpy.nan, and any value greater than this threshold to this number (default: 1.e9)

Example Config YAML File

Highlighted regions are used by this method, other options are ignored.

xdata:
    dimensions            : ['x', 'time']
#
    zstore_path           : lorenz96-12d.zarr
    field_name            : 'trajectory'
    subsampling:
        time:
            training        : [  2_000, 42_001, null]
            macro_training  : [ 42_000, 52_001, null]
            testing         : [ 57_000,   null, null]

    normalization:
        bias            : 2.38565488 # computed from trainer.mean
        scale           : 3.65852722 # computed from trainer.std

esn:
    n_input             : 12
    n_output            : 12
    n_reservoir         : 1_000
    leak_rate           : 0.5
    tikhonov_parameter  : 1.e-6
#
    input_kwargs:
        factor          : 0.5
        distribution    : uniform
        normalization   : svd
        is_sparse       : False
        random_seed     : 0
#
    adjacency_kwargs:
        factor          : 0.9
        distribution    : uniform
        normalization   : svd
        is_sparse       : True
        connectedness   : 5
        random_seed     : 1
#
    bias_kwargs:
        factor          : 0.
        distribution    : uniform
        random_seed     : 2

training:
    n_spinup            : 0
    batch_size          : 20_000

esn_weights:
    store               : output-guess/esn-weights.zarr

testing:
    n_spinup            : 100
    n_samples           : 20
    n_steps             : 500
    random_seed         : 10
    cost_terms:
        nrmse           : 1.
        psd_nrmse       : 1.

macro_training:
    parameters:
        input_factor    : [0., 2.]
        adjacency_factor: [0., 2.]
        bias_factor     : [0., 2.]
        leak_rate       : [0., 1.]
        tikhonov_parameter : [1.e-12, 1.]

    transformations:
        tikhonov_parameter : log10

    forecast:
        n_spinup        : 100
        n_samples       : 5
        n_steps         : 500
        random_seed     : 10

    ego:
        n_iter          : 5
        n_doe           : 10
        n_parallel      : 4
        random_state    : 5

    cost_upper_bound    : 1.e9
    cost_terms:
        nrmse           : 1.
        psd_nrmse       : 1.