This Vignette is supposed to give you a short introduction and a glance at the key features of mlrHyperopt
. For updated information make sure to check the GitHub project page:
The main goal of mlrHyperopt
is to break boundaries and make Hyperparameter optimization super easy. Often beginners of machine learning and even experts don’t know which parameters have to be tuned for certain machine learning methods. Sometimes experts also don’t necessarily agree on the tuning parameters and their ranges. This package tries to tackle these problems by offering:
As the name indicates mlrHyperopt
relies heavily on mlr
. Additionally mlrMBO
will be used automatically for pure numeric Parameter Spaces of dimension 2 or higher. Most used objects are documented in mlr
. To create your own task
check the mlr-tutorial on how to create Learning Tasks, Learners, Tuning Parameter Sets for Learners, as well as custom resampling strategies.
Hyperparameter Tuning with mlrHyperopt
can be done in one line:
## Tune result:
## Op. pars: nodesize=10; mtry=2
## mmce.test.mean=0.0466667
To obtain full control of what is happening you can define every argument yourself or just depend partially on the automatic processes.
pc = generateParConfig(learner = "classif.randomForest")
# The tuning parameter set:
getParConfigParSet(pc)
## Type len Def Constr Req Tunable Trafo
## nodesize integer - 1 1 to 10 - TRUE -
## mtry integer - floor(sqrt(p)) 1 to p - TRUE -
# Setting constant values:
pc = setParConfigParVals(pc, par.vals = list(mtry = 3))
hc = generateHyperControl(task = iris.task, par.config = pc)
# Inspecting the resamling strategy used for tuning
getHyperControlResampling(hc)
## Resample description: cross-validation with 10 iterations.
## Predict: test
## Stratification: FALSE
# Changing the resampling strategy
hc = setHyperControlResampling(hc, makeResampleDesc("Bootstrap", iters = 3))
# Starting the hyperparameter tuning
res = hyperopt(iris.task, par.config = pc, hyper.control = hc, show.info = FALSE)
res
## Tune result:
## Op. pars: nodesize=5; mtry=3
## mmce.test.mean=0.0297386