getCaretParamSet: Get tuning parameters from a learner of the caret R-package.

Description Usage Arguments Value Examples

View source: R/getCaretParamSet.R

Description

Constructs a grid of tuning parameters from a learner of the caret R-package. These values are then converted into a list of non-tunable parameters (par.vals) and a tunable ParamSet (par.set), which can be used by tuneParams for tuning the learner. Numerical parameters will either be specified by their lower and upper bounds or they will be discretized into specific values.

Usage

1
getCaretParamSet(learner, length = 3L, task, discretize = TRUE)

Arguments

learner

[character(1)]
The name of the learner from caret (cf. https://topepo.github.io/caret/available-models.html). Note that the names in caret often differ from the ones in mlr.

length

[integer(1)]
A length / precision parameter which is used by caret for generating the grid of tuning parameters. caret generates either as many values per tuning parameter / dimension as defined by length or only a single value (in case of non-tunable par.vals).

task

[Task]
Learning task, which might be requested for creating the tuning grid.

discretize

[logical(1)]
Should the numerical parameters be discretized? Alternatively, they will be defined by their lower and upper bounds. The default is TRUE.

Value

[list(2)]. A list of parameters:

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
if (requireNamespace("caret") && requireNamespace("mlbench")) {
  library(caret)
  classifTask = makeClassifTask(data = iris, target = "Species")

  # (1) classification (random forest) with discretized parameters
  getCaretParamSet("rf", length = 9L, task = classifTask, discretize = TRUE)

  # (2) regression (gradient boosting machine) without discretized parameters
  library(mlbench)
  data(BostonHousing)
  regrTask = makeRegrTask(data = BostonHousing, target = "medv")
  getCaretParamSet("gbm", length = 9L, task = regrTask, discretize = FALSE)
}

riebetob/mlr documentation built on May 20, 2019, 5:58 p.m.