43 lines
953 B
R
43 lines
953 B
R
|
|
#' Performs a grid search for parameters over a parameter grid.
|
|
#' @examples
|
|
#' args <- list(
|
|
#' h = c(0.05, 0.1, 0.2),
|
|
#' method = c("simple", "sgd"),
|
|
#' tau = c(0.5, 0.1, 0.01)
|
|
#' )
|
|
#' cve.grid.search(args)
|
|
#' @export
|
|
cve.grid.search <- function(X, Y, k, args) {
|
|
|
|
args$stringsAsFactors = FALSE
|
|
args$KEEP.OUT.ATTRS = FALSE
|
|
grid <- do.call(expand.grid, args)
|
|
grid.length <- length(grid[[1]])
|
|
|
|
print(grid)
|
|
|
|
for (i in 1:grid.length) {
|
|
arguments <- as.list(grid[i, ])
|
|
# Set required arguments
|
|
arguments$X <- X
|
|
arguments$Y <- Y
|
|
arguments$k <- k
|
|
# print(arguments)
|
|
dr <- do.call(cve.call, arguments)
|
|
print(dr$loss)
|
|
}
|
|
}
|
|
|
|
# ds <- dataset()
|
|
# X <- ds$X
|
|
# Y <- ds$Y
|
|
# (k <- ncol(ds$B))
|
|
# args <- list(
|
|
# h = c(0.05, 0.1, 0.2),
|
|
# method = c("simple", "sgd"),
|
|
# tau = c(0.5, 0.1, 0.01),
|
|
# attempts = c(1L)
|
|
# )
|
|
|
|
# cve.grid.search(X, Y, k, args) |