Learn R Programming

targeted (version 0.6)

learner_expand_grid: Construct learners from a grid of parameters

Description

Construct learners from a grid of parameters

Usage

learner_expand_grid(fun, args, names = TRUE, params = FALSE)

Value

list

Arguments

fun

(function) A function that returns a learner.

args

(list) Parameters that generate a grid of parameters with expand.list, where the set of parameters are then passed on to fun.

names

(logical or character) If FALSE, then return a list without names. If TRUE, a named list is returned (see details).

params

(logical) If FALSE, then no information about the parameters defined by args are added to the names of the returned list.

Examples

Run this code
lrs <- learner_expand_grid(
  learner_xgboost,
  list(formula = Sepal.Length ~ ., eta = c(0.2, 0.5, 0.3))
)
lrs # use info of constructed learner as names

lrs <- learner_expand_grid(
  learner_xgboost,
  list(formula = Sepal.Length ~ ., eta = c(0.2, 0.5, 0.3)),
  names = "xgboost"
)
names(lrs) # use xgboost instead of info field for names

lrs <- learner_expand_grid(
  learner_xgboost,
  list(formula = Sepal.Length ~ ., eta = c(0.2, 0.5, 0.3)),
  names = "xgboost",
  params = TRUE
)
names(lrs) # also add parameters to names

lrs <- learner_expand_grid(
  learner_xgboost,
  list(formula = Sepal.Length ~ ., eta = c(0.2, 0.5, 0.3)),
  names = FALSE
)
names(lrs) # unnamed list since names = FALSE

Run the code above in your browser using DataLab