Skip to contents

This function creates a regular hyperparameter search grid (in the form of a tibble) specifying the search space for the two hyperparameters of a generalized linear model using the glmnet package: the regularization penalty term and the lasso/ridge regression mixture term.

Usage

tof_create_grid(
  penalty_values,
  mixture_values,
  num_penalty_values = 5,
  num_mixture_values = 5
)

Arguments

penalty_values

A numeric vector of the unique elastic net penalty values ("lambda") to include in the hyperparameter grid. If unspecified, a regular grid with `num_penalty_values` between 10^(-10) and 10^(0) will be used.

mixture_values

A numeric vector of all elastic net mixture values ("alpha") to include in the hyperparameter grid. If unspecified, a regular grid with `num_mixture_values` between 0 and 1 will be used.

num_penalty_values

Optional. If `penalty_values` is not supplied, `num_penalty_values` (an integer) can be given to specify how many equally-spaced penalty values between 10^(-10) and 1 should be included in the hyperparameter grid. If this method is used, the regular grid will always be returned. Defaults to 5.

num_mixture_values

Optional. If `mixture_values` is not supplied, `num_mixture_values` (an integer) can be given to specify how many equally-spaced penalty values between 0 (ridge regression) and 1 (lasso) should be included in the hyperparameter grid. If this method is used, the regular grid will always be returned. Defaults to 5.

Value

A tibble with two numeric columns: `penalty` and `mixture`.

See also

Other modeling functions: tof_assess_model(), tof_predict(), tof_split_data(), tof_train_model()

Examples

tof_create_grid()
#> # A tibble: 25 × 2
#>         penalty mixture
#>           <dbl>   <dbl>
#>  1 0.0000000001    0   
#>  2 0.0000000001    0.25
#>  3 0.0000000001    0.5 
#>  4 0.0000000001    0.75
#>  5 0.0000000001    1   
#>  6 0.0000000316    0   
#>  7 0.0000000316    0.25
#>  8 0.0000000316    0.5 
#>  9 0.0000000316    0.75
#> 10 0.0000000316    1   
#> # ℹ 15 more rows

tof_create_grid(num_penalty_values = 10, num_mixture_values = 5)
#> # A tibble: 50 × 2
#>          penalty mixture
#>            <dbl>   <dbl>
#>  1 0.0000000001     0   
#>  2 0.0000000001     0.25
#>  3 0.0000000001     0.5 
#>  4 0.0000000001     0.75
#>  5 0.0000000001     1   
#>  6 0.00000000129    0   
#>  7 0.00000000129    0.25
#>  8 0.00000000129    0.5 
#>  9 0.00000000129    0.75
#> 10 0.00000000129    1   
#> # ℹ 40 more rows

tof_create_grid(penalty_values = c(0.01, 0.1, 0.5))
#> # A tibble: 15 × 2
#>    penalty mixture
#>      <dbl>   <dbl>
#>  1    0.01    0   
#>  2    0.01    0.25
#>  3    0.01    0.5 
#>  4    0.01    0.75
#>  5    0.01    1   
#>  6    0.1     0   
#>  7    0.1     0.25
#>  8    0.1     0.5 
#>  9    0.1     0.75
#> 10    0.1     1   
#> 11    0.5     0   
#> 12    0.5     0.25
#> 13    0.5     0.5 
#> 14    0.5     0.75
#> 15    0.5     1