hyperparameter_tuning: Hyperparameter tuning

hyperparameter_tuningR Documentation

Hyperparameter tuning

Description

Pick best-performing hyperparameters for a given dataset. n_timesteps_grid has default grid for predicting quarterly variable with monthly series, may have to change per use case. E.g. [12,24] for a yearly target with monthly indicators. All parameters up to 'optimizer_parameters' exactly the same as for any LSTM() model, provide a list with the values to check.

Usage

hyperparameter_tuning(
  data,
  target_variable,
  n_models = 1,
  n_timesteps_grid = c(6, 12),
  fill_na_func_grid = c("mean"),
  fill_ragged_edges_func_grid = c("mean"),
  train_episodes_grid = c(50, 100, 200),
  batch_size_grid = c(30, 100, 200),
  decay_grid = c(0.98),
  n_hidden_grid = c(10, 20, 40),
  n_layers_grid = c(1, 2, 4),
  dropout_grid = c(0),
  criterion_grid = c("''"),
  optimizer_grid = c("''"),
  optimizer_parameters_grid = c(list(lr = 0.01)),
  n_folds = 1,
  init_test_size = 0.2,
  pub_lags = c(),
  lags = c(),
  performance_metric = "RMSE",
  quiet = FALSE
)

Arguments

n_folds

how many folds for rolling fold validation to do

init_test_size

ϵ [0,1]. What proportion of the data to use for testing at the first fold

pub_lags

list of periods back each input variable is set to missing. I.e. publication lag of the variable. Leave empty to pick variables only on complete information, no synthetic vintages.

lags

simulated periods back to test when selecting variables. E.g. -2 = simulating data as it would have been 2 months before target period, 1 = 1 month after, etc. So [-2, 0, 2] will account for those vintages in model selection. Leave empty to pick variables only on complete information, no synthetic vintages.

performance_metric

performance metric to use for variable selection. Pass "RMSE" for root mean square error, "MAE" for mean absolute error, or "AICc" for correctd Akaike Information Criterion. Alternatively can pass a function that takes arguments of a pandas Series of predictions and actuals and returns a scalar. E.g. custom_function(preds, actuals).

Value

A dataframe containing the following elements:

hyper_params

liste of hyperparameters, access via df$hyper_params[[1]], etc.

performance

performance metric of these hyperparameteres


dhopp1/nowcastLSTM documentation built on May 7, 2024, 9:30 a.m.