Description Usage Arguments Value Examples
Runs hyperband
1 2 |
problem |
[ |
max.resources |
[ |
prop.discard |
[ |
max.perf |
[ |
id |
[ |
par.set |
|
sample.fun |
|
init.fun |
|
train.fun |
|
performance.fun |
The function to measure the performance |
... |
Further arguments |
List of brackets
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | # we need some packages
library("ggplot2")
library("smoof")
library("data.table")
# we choose the 2 dimensional branin function
braninProb = makeBraninFunction()
# the branin function has 3 global minima
opt = data.table(x1 = getGlobalOptimum(braninProb)$param$x1,
x2 = getGlobalOptimum(braninProb)$param$x2)
param.set = getParamSet(braninProb)
#######################################
## define functions to use hyperband ##
#######################################
# config space
configSpace = makeParamSet(
makeNumericParam(id = "x1", lower = -5, upper = 10.1))
# sample fun
sample.fun = function(par.set, n.configs, ...) {
sampleValues(par = par.set, n = n.configs)
}
# init fun
init.fun = function(r, config, problem) {
x1 = unname(unlist(config))
x2 = runif(1, 0, 15)
mod = c(x1, x2)
return(mod)
}
# train fun
train.fun = function(mod, budget, problem) {
for(i in seq_len(budget)) {
mod.new = c(mod[[1]], mod[[2]] + rnorm(1, sd = 3))
if(performance.fun(mod.new) < performance.fun(mod))
mod = mod.new
}
return(mod)
}
# performance fun
performance.fun = function(model, problem) {
braninProb(c(model[[1]], model[[2]]))
}
hyperhyper = hyperband(
problem = braninProb,
max.resources = 81,
prop.discard = 3,
max.perf = FALSE,
id = "branin",
par.set = configSpace,
sample.fun = sample.fun,
init.fun = init.fun,
train.fun = train.fun,
performance.fun = performance.fun)
# get the best performance of each bracket
lapply(hyperhyper, function(x) x$getPerformances())
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.