Skip to contents

Generate a data frame of possible alpha values to evaluate during training

Usage

list_sampled_alphas(
  n_target = 100,
  alpha_lower = 0,
  alpha_upper = 1,
  alpha_seasonal_lower = 0,
  alpha_seasonal_upper = 1,
  alpha_seasonal_decay_lower = 0,
  alpha_seasonal_decay_upper = 1,
  oversample_lower = 0.05,
  oversample_upper = 0.05,
  include_edge_cases = FALSE,
  seed = NULL
)

Arguments

n_target

The targeted number of 3-parameter tuples; since the tuples are generated by a one-time shot sampling (instead of, e.g., rejection sampling) and only distinct samples are returned, the realized length of the list of tuples may be shorter than n_target. Especially when oversample_lower and/or oversample_upper are large compared to the allowed parameter range, the realized length of the resulting list can be shorter than n_target as many tuples become {0,1}-valued.

alpha_lower

A numeric scalar in 0,1 serving as lower bound applied to the alpha parameter of the returned tuples

alpha_upper

A numeric scalar in 0,1 serving as upper bound applied to the alpha parameter of the returned tuples; must be at least as large as alpha_lower. When equal to alpha_lower, samples for alpha will be equal to alpha_lower will be equal to alpha_upper (as that is the only allowed value).

alpha_seasonal_lower

A numeric scalar in 0,1 serving as lower bound applied to the alpha_seasonal parameter of the returned tuples

alpha_seasonal_upper

A numeric scalar in 0,1 serving as upper bound applied to the alpha_seasonal parameter of the returned tuples; must be at least as large as alpha_seasonal_lower. When equal to alpha_seasonal_lower, samples for alpha_seasonal will be equal to alpha_seasonal_lower will be equal to alpha_seasonal_upper (as that is the only allowed value).

alpha_seasonal_decay_lower

A numeric scalar in 0,1 serving as lower bound applied to the alpha_seasonal_decay parameter of returned tuples

alpha_seasonal_decay_upper

A numeric scalar in 0,1 serving as upper bound applied to the alpha_seasonal_decay parameter of the returned tuples; must be at least as large as alpha_seasonal_decay_lower. When equal to alpha_seasonal_decay_lower, samples for alpha_seasonal_decay will be equal to alpha_seasonal_decay_lower will be equal to alpha_seasonal_decay_upper (as that is the only allowed value).

oversample_lower

A non-negative numeric scalar adding additional weight to the parameters' lower bounds during sampling. Since the sampling generally draws values from a continuous range, the border cases of the exact lower and upper bound (especially 0 and 1) would never be drawn even though they represent often well performing special cases. By specifying oversample_lower, explicit probability is assigned to the lower bound value. Extends the lower bounds alpha_lower, alpha_seasonal_lower, alpha_seasonal_decay_lower to alpha_lower - oversample_lower etc. during sampling of parameters via runif(min = alpha_lower - oversample_lower, ...) etc. After sampling, parameter values are thresholded back to alpha_lower etc. For the default case of lower bounds equal to 0 and upper bounds equal to 1, the choice of oversample_lower = 0.05 creates a roughly 5% probability of returning exactly the lower bound value of 0 as parameter value.

oversample_upper

A non-negative numeric scalar adding additional weight to the parameters' upper bounds during sampling. Since the sampling generally draws values from a continuous range, the border cases of the exact lower and upper bound (especially 0 and 1) would never be drawn even though they represent often well performing special cases. By specifying oversample_upper, explicit probability is assigned to the upper bound value. Extends the upper bounds alpha_upper, alpha_seasonal_upper, alpha_seasonal_decay_upper to alpha_upper + oversample_upper etc. during sampling of parameters via runif(max = alpha_upper + oversample_upper, ...) etc. After sampling, parameter values are thresholded back to alpha_upper etc. For the default case of lower bounds equal to 0 and upper bounds equal to 1, the choice of oversample_lower = 0.05 creates a roughly 5% probability of returning exactly the lower bound value of 1 as parameter value.

include_edge_cases

Logical; if TRUE, a hardcoded set of tuples representing special cases of model specifications will be included. Since these take currently five entries of the list, this is only be useful when n_target is at least of length five. Otherwise the returned list will contain only (a subset of) the special cases. To achieve that, list_edge_alphas() is the preferred method. Including the special cases will lead to a comparison of sampled parameters to benchmarks such as the mean forecast, random walk forecast, or seasonal naive forecast.

seed

A random seed used while sampling parameters. Will reset the .Random.seed to its value before the function call upon exit.

Value

A data frame with columns alpha, alpha_seasonal, and alpha_seasonal_decay and at most n_target rows; all values are between 0 and 1

Examples

alphas_grid <- list_sampled_alphas(n_target = 1000L)

if (require("ggplot2")) {
ggplot2::ggplot(
  alphas_grid,
  ggplot2::aes(x = alpha, y = alpha_seasonal, fill = alpha_seasonal_decay)
) +
  ggplot2::geom_point(pch = 21, color = "white") +
  ggplot2::scale_fill_gradient2(midpoint = 0.5) +
  ggplot2::labs(title = "Sampled Grid of Parameters to Evaluate")
}