This is the abstract base class for parameter objects like ParamDbl and ParamFct.
as.data.table()
Param -> data.table::data.table()
Converts param to data.table::data.table()
with 1 row. See ParamSet.
id
(character(1)
)
Identifier of the object.
special_vals
(list()
)
Arbitrary special values this parameter is allowed to take.
default
(any
)
Default value.
tags
(character()
)
Arbitrary tags to group and subset parameters.
class
(character(1)
)
R6 class name. Read-only.
is_number
(logical(1)
)
TRUE
if the parameter is of type "dbl"
or "int"
.
is_categ
(logical(1)
)
TRUE
if the parameter is of type "fct"
or "lgl"
.
has_default
(logical(1)
)
Is there a default value?
new()
Creates a new instance of this R6 class.
Note that this object is typically constructed via derived classes, e.g., ParamDbl.
Param$new(id, special_vals, default, tags)
id
(character(1)
)
Identifier of the object.
special_vals
(list()
)
Arbitrary special values this parameter is allowed to take, to make it
feasible. This allows extending the domain of the parameter. Note that
these values are only used in feasibility checks, neither in generating
designs nor sampling.
default
(any
)
Default value. Can be from the domain of the parameter or an element of
special_vals
. Has value NO_DEF if no default exists. NULL
can be a
valid default.
The value has no effect on ParamSet$values
or the behavior of
ParamSet$check()
, $test()
or $assert()
.
The default
is intended to be used for documentation purposes.
`
tags
(character()
)
Arbitrary tags to group and subset parameters. Some tags serve a special
purpose:
"required"
implies that the parameters has to be given when setting
values
in ParamSet.
check()
checkmate-like check-function. Take a value from the domain of the
parameter, and check if it is feasible. A value is feasible if it is of
the same storage_type
, inside of the bounds or element of
special_vals
.
Param$check(x)
x
(any
).
If successful TRUE
, if not a string with the error message.
assert()
checkmate-like assert-function. Take a value from the domain of
the parameter, and assert if it is feasible. A value is feasible if it
is of the same storage_type
, inside of the bounds or element of
special_vals
.
Param$assert(x)
x
(any
).
If successful x
invisibly, if not an exception is raised.
test()
checkmate-like test-function. Take a value from the domain of the
parameter, and test if it is feasible. A value is feasible if it is of
the same storage_type
, inside of the bounds or element of
special_vals
.
Param$test(x)
x
(any
).
If successful TRUE
, if not FALSE
.
rep()
Repeats this parameter n-times (by cloning). Each parameter is named "[id]rep[k]" and gets the additional tag "[id]_rep".
Param$rep(n)
n
(integer(1)
).
format()
Helper for print outputs.
Param$format()
print()
Printer.
Param$print( ..., hide_cols = c("nlevels", "is_bounded", "special_vals", "tags", "storage_type") )
...
(ignored).
hide_cols
(character()
)
Which fields should not be printed? Default is "nlevels"
,
"is_bounded"
, "special_vals"
, "tags"
, and "storage_type"
.
qunif()
Takes values from [0,1] and maps them, regularly distributed, to the domain of the parameter. Think of: quantile function or the use case to map a uniform-[0,1] random variable into a uniform sample from this param.
Param$qunif(x)
x
(numeric(1)
).
Value of the domain of the parameter.
convert()
Converts a value to the closest valid param. Only for values that
pass $check()
and mostly used internally.
Param$convert(x)
x
(any
).
x
converted to a valid type for the Param
.
clone()
The objects of this class are cloneable with this method.
Param$clone(deep = FALSE)
deep
Whether to make a deep clone.
Other Params:
ParamDbl
,
ParamFct
,
ParamInt
,
ParamLgl
,
ParamUty