Param {paradox} | R Documentation |
Param Class
Description
This is the abstract base class for parameter objects like ParamDbl and ParamFct.
S3 methods
-
as.data.table()
Param ->data.table::data.table()
Converts param todata.table::data.table()
with 1 row. See ParamSet.
Public fields
id
(
character(1)
)
Identifier of the object.description
(
character(1)
)
String to describe this parameter. Used, for example, inmlr3misc::rd_info()
to automatically generate documentation for parameter sets.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.
Active bindings
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?
Methods
Public methods
Method new()
Creates a new instance of this R6 class.
Note that this object is typically constructed via derived classes, e.g., ParamDbl.
Usage
Param$new(id, special_vals, default, tags)
Arguments
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 ofspecial_vals
. Has value NO_DEF if no default exists.NULL
can be a valid default. The value has no effect onParamSet$values
or the behavior ofParamSet$check()
,$test()
or$assert()
. Thedefault
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 settingvalues
in ParamSet.
-
Method 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
.
Usage
Param$check(x)
Arguments
x
(
any
).
Returns
If successful TRUE
, if not a string with the error message.
Method 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
.
Usage
Param$assert(x)
Arguments
x
(
any
).
Returns
If successful x
invisibly, if not an exception is raised.
Method 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
.
Usage
Param$test(x)
Arguments
x
(
any
).
Returns
If successful TRUE
, if not FALSE
.
Method rep()
Repeats this parameter n-times (by cloning). Each parameter is named "[id]rep[k]" and gets the additional tag "[id]_rep".
Usage
Param$rep(n)
Arguments
n
(
integer(1)
).
Returns
Method format()
Helper for print outputs.
Usage
Param$format(...)
Arguments
...
(ignored).
Method print()
Printer.
Usage
Param$print( ..., hide_cols = c("nlevels", "is_bounded", "special_vals", "tags", "storage_type") )
Arguments
...
(ignored).
hide_cols
(
character()
)
Which fields should not be printed? Default is"nlevels"
,"is_bounded"
,"special_vals"
,"tags"
, and"storage_type"
.
Method 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.
Usage
Param$qunif(x)
Arguments
x
(
numeric(1)
).
Returns
Value of the domain of the parameter.
Method convert()
Converts a value to the closest valid param. Only for values that
pass $check()
and mostly used internally.
Usage
Param$convert(x)
Arguments
x
(
any
).
Returns
x
converted to a valid type for the Param
.
Method clone()
The objects of this class are cloneable with this method.
Usage
Param$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Other Params:
ParamDbl
,
ParamFct
,
ParamInt
,
ParamLgl
,
ParamUty