Skip to contents

Validation split order comes from the shared LCG stream, not numpy's PCG64 permutation.

Usage

morie_geron_hidden_layers_heuristic(
  model,
  X,
  y,
  max_layers = 10,
  min_layers = 1,
  patience = 2,
  tol = 1e-04,
  val_fraction = 0.2,
  seed = 0
)

Arguments

model

function(n_layers, X_train, y_train, X_val, y_val) -> val_error.

X, y

Data.

max_layers, min_layers

Depth range.

patience

Non-improving depths tolerated.

tol

Minimum improvement.

val_fraction

Held-out fraction.

seed

Split seed.

Value

List with best_n_layers, best_error, errors, depths_tried, stopped_early, estimate, n, method.

Examples

X <- matrix(c(1, 2, 3, 4), ncol = 1)
y <- c(3, 6, 9, 12)
vshape <- function(L, Xt, yt, Xv, yv) abs(L - 3) + 0.5
morie_geron_hidden_layers_heuristic(vshape, X, y, max_layers = 10,
    patience = 2)
#> $best_n_layers
#> [1] 3
#> 
#> $best_error
#> [1] 0.5
#> 
#> $errors
#> $errors$`1`
#> [1] 2.5
#> 
#> $errors$`2`
#> [1] 1.5
#> 
#> $errors$`3`
#> [1] 0.5
#> 
#> $errors$`4`
#> [1] 1.5
#> 
#> $errors$`5`
#> [1] 2.5
#> 
#> 
#> $depths_tried
#> [1] 5
#> 
#> $stopped_early
#> [1] TRUE
#> 
#> $estimate
#> [1] 0.5
#> 
#> $n
#> [1] 4
#> 
#> $method
#> [1] "Depth selection by validation-error plateau"
#>