setHyperPars: Set the hyperparameters of a learner object.

View source: R/setHyperPars.R

setHyperParsR Documentation

Set the hyperparameters of a learner object.

Description

Set the hyperparameters of a learner object.

Usage

setHyperPars(learner, ..., par.vals = list())

Arguments

learner

(Learner | character(1))
The learner. If you pass a string the learner will be created via makeLearner.

...

(any)
Optional named (hyper)parameters. If you want to set specific hyperparameters for a learner during model creation, these should go here. You can get a list of available hyperparameters using ⁠getParamSet(<learner>)⁠. Alternatively hyperparameters can be given using the par.vals argument but ... should be preferred!

par.vals

(list)
Optional list of named (hyper)parameters. The arguments in ... take precedence over values in this list. We strongly encourage you to use ... for passing hyperparameters.

Value

Learner.

Note

If a named (hyper)parameter can't be found for the given learner, the 3 closest (hyper)parameter names will be output in case the user mistyped.

See Also

Other learner: LearnerProperties, getClassWeightParam(), getHyperPars(), getLearnerId(), getLearnerNote(), getLearnerPackages(), getLearnerParVals(), getLearnerParamSet(), getLearnerPredictType(), getLearnerShortName(), getLearnerType(), getParamSet(), helpLearnerParam(), helpLearner(), makeLearners(), makeLearner(), removeHyperPars(), setId(), setLearnerId(), setPredictThreshold(), setPredictType()

Examples

cl1 = makeLearner("classif.ksvm", sigma = 1)
cl2 = setHyperPars(cl1, sigma = 10, par.vals = list(C = 2))
print(cl1)
# note the now set and altered hyperparameters:
print(cl2)

berndbischl/mlr documentation built on Aug. 15, 2024, 4:20 p.m.