Domain | R Documentation |
A Domain
object is a representation of a single dimension of a ParamSet
. Domain
objects are used to construct
ParamSet
s, either through the ps()
short form, through the ParamSet
constructor itself,
or through the ParamSet
$search_space()
mechanism (see
to_tune()
).
For each of the basic parameter classes ("ParamInt"
, "ParamDbl"
, "ParamLgl"
, "ParamFct"
, and "ParamUty"
) there is a function constructing a Domain
object
(p_int()
, p_dbl()
, p_lgl()
, p_fct()
, p_uty()
). They each have fitting construction arguments that control their
bounds and behavior.
Domain
objects are representations of parameter ranges and are intermediate objects to be used in short form
constructions in to_tune()
and ps()
. Because of their nature, they should not be modified by the user, once constructed.
The Domain
object's internals are subject to change and should not be relied upon.
p_dbl(
lower = -Inf,
upper = Inf,
special_vals = list(),
default = NO_DEF,
tags = character(),
tolerance = sqrt(.Machine$double.eps),
depends = NULL,
trafo = NULL,
logscale = FALSE,
init,
aggr = NULL,
in_tune_fn = NULL,
disable_in_tune = NULL
)
p_fct(
levels,
special_vals = list(),
default = NO_DEF,
tags = character(),
depends = NULL,
trafo = NULL,
init,
aggr = NULL,
in_tune_fn = NULL,
disable_in_tune = NULL
)
p_int(
lower = -Inf,
upper = Inf,
special_vals = list(),
default = NO_DEF,
tags = character(),
tolerance = sqrt(.Machine$double.eps),
depends = NULL,
trafo = NULL,
logscale = FALSE,
init,
aggr = NULL,
in_tune_fn = NULL,
disable_in_tune = NULL
)
p_lgl(
special_vals = list(),
default = NO_DEF,
tags = character(),
depends = NULL,
trafo = NULL,
init,
aggr = NULL,
in_tune_fn = NULL,
disable_in_tune = NULL
)
p_uty(
custom_check = NULL,
special_vals = list(),
default = NO_DEF,
tags = character(),
depends = NULL,
trafo = NULL,
repr = substitute(default),
init,
aggr = NULL,
in_tune_fn = NULL,
disable_in_tune = NULL
)
lower |
( |
upper |
( |
special_vals |
( |
default |
( |
tags |
(
|
tolerance |
( |
depends |
( |
trafo |
( |
logscale |
( |
init |
( |
aggr |
( |
in_tune_fn |
( |
disable_in_tune |
(named |
levels |
( |
custom_check |
( |
repr |
( |
Although the levels
values of a constructed p_fct()
will always be character
-valued, the p_fct
function admits
a levels
argument that goes beyond this:
Besides a character
vector, any atomic vector or list (optionally named) may be given. (If the value is a list
that is not named, the names are inferred using as.character()
on the values.) The resulting Domain
will
correspond to a range of values given by the names of the levels
argument with a trafo
that maps the character
names to the arbitrary values of the levels
argument.
A Domain
object.
Other ParamSet construction helpers:
ps()
,
to_tune()
params = ps(
unbounded_integer = p_int(),
bounded_double = p_dbl(0, 10),
half_bounded_integer = p_dbl(1),
half_bounded_double = p_dbl(upper = 1),
double_with_trafo = p_dbl(-1, 1, trafo = exp),
extra_double = p_dbl(0, 1, special_vals = list("xxx"), tags = "tagged"),
factor_param = p_fct(c("a", "b", "c")),
factor_param_with_implicit_trafo = p_fct(list(a = 1, b = 2, c = list()))
)
print(params)
params$trafo(list(
bounded_double = 1,
double_with_trafo = 1,
factor_param = "c",
factor_param_with_implicit_trafo = "c"
))
# logscale:
params = ps(x = p_dbl(1, 100, logscale = TRUE))
# The ParamSet has bounds log(1) .. log(100):
print(params)
# When generating a equidistant grid, it is equidistant within log values
grid = generate_design_grid(params, 3)
print(grid)
# But the values are on a log scale with desired bounds after trafo
print(grid$transpose())
# Integer parameters with logscale are `p_dbl()`s pre-trafo
params = ps(x = p_int(0, 10, logscale = TRUE))
print(params)
grid = generate_design_grid(params, 4)
print(grid)
# ... but get transformed to integers.
print(grid$transpose())
# internal tuning
param_set = ps(
iters = p_int(0, Inf, tags = "internal_tuning", aggr = function(x) round(mean(unlist(x))),
in_tune_fn = function(domain, param_vals) {
stopifnot(domain$lower <= 1)
stopifnot(param_vals$early_stopping == TRUE)
domain$upper
},
disable_in_tune = list(early_stopping = FALSE)),
early_stopping = p_lgl()
)
param_set$set_values(
iters = to_tune(upper = 100, internal = TRUE),
early_stopping = TRUE
)
param_set$convert_internal_search_space(param_set$search_space())
param_set$aggr_internal_tuned_values(
list(iters = list(1, 2, 3))
)
param_set$disable_internal_tuning("iters")
param_set$values$early_stopping
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.