Learn R Programming

mlr (version 2.3)

tuneParams: Hyperparameter tuning.

Description

Optimizes the hyperparameters of a learner. Allows for different optimization methods, such as grid search, evolutionary strategies, iterated F-race, etc. You can select such an algorithm (and its settings) by passing a corresponding control object. For a complete list of implemented algorithms look at TuneControl.

Multi-criteria tuning can be done with tuneParamsMultiCrit.

Usage

tuneParams(learner, task, resampling, measures, par.set, control,
  show.info = getMlrOption("show.info"))

Arguments

Value

[TuneResult].

See Also

Other tune: ModelMultiplexer, makeModelMultiplexer; TuneControl, TuneControlCMAES, TuneControlGenSA, TuneControlGrid, TuneControlIrace, TuneControlRandom, makeTuneControlCMAES, makeTuneControlGenSA, makeTuneControlGrid, makeTuneControlIrace, makeTuneControlRandom; getTuneResult; makeModelMultiplexerParamSet; makeTuneWrapper; tuneThreshold

Examples

Run this code
# a grid search for an SVM (with a tiny number of points...)
# note how easily we can optimize on a log-scale
ps = makeParamSet(
  makeNumericParam("C", lower = -12, upper = 12, trafo = function(x) 2^x),
  makeNumericParam("sigma", lower = -12, upper = 12, trafo = function(x) 2^x)
)
ctrl = makeTuneControlGrid(resolution = 2L)
rdesc = makeResampleDesc("CV", iters = 2L)
res = tuneParams("classif.ksvm", iris.task, rdesc, par.set = ps, control = ctrl)
print(res)
print(as.data.frame(res$opt.path))
print(as.data.frame(trafoOptPath(res$opt.path)))

# we optimize the SVM over 3 kernels simultanously
# note how we use dependent params (requires = ...) and iterated F-racing here
ps = makeParamSet(
  makeNumericParam("C", lower = -12, upper = 12, trafo = function(x) 2^x),
  makeDiscreteParam("kernel", values = c("vanilladot", "polydot", "rbfdot")),
  makeNumericParam("sigma", lower = -12, upper = 12, trafo = function(x) 2^x,
    requires = quote(kernel == "rbfdot")),
  makeIntegerParam("degree", lower = 2L, upper = 5L,
    requires = quote(kernel == "polydot"))
)
print(ps)
ctrl = makeTuneControlIrace(maxExperiments = 200L)
rdesc = makeResampleDesc("Holdout")
res = tuneParams("classif.ksvm", iris.task, rdesc, par.set = ps, control = ctrl)
print(res)
print(head(as.data.frame(res$opt.path)))

Run the code above in your browser using DataLab