A set of Param objects.
Please note that when creating a set or adding to it, the parameters of the
resulting set have to be uniquely named with IDs with valid R names.
The set also contains a member variable values
which can be used to store an active configuration /
or to partially fix
some parameters to constant values (regarding subsequent sampling or generation of designs).
S3 methods and type converters
as.data.table()
ParamSet ->data.table::data.table()
Compact representation as datatable. Col types are:id: character
lower, upper: double
levels: list col, with NULL elements
special_vals: list col of list
is_bounded: logical
default: list col, with NULL elements
storage_type: character
tags: list col of character vectors
Public fields
assert_values
(
logical(1)
)
Should values be checked for validity during assigment to active binding$values
? Default isTRUE
, only switch this off if you know what you are doing.
Active bindings
params
(named
list()
)
List of Param, named with their respective ID.params_unid
(named
list()
)
List of Param, named with their true ID. However, this field has the Param's$id
value set to a potentially invalid value. This active binding should only be used internally.deps
(
data.table::data.table()
)
Table has colsid
(character(1)
) andon
(character(1)
) andcond
(Condition). Lists all (direct) dependency parents of a param, through parameter IDs. Internally created by a call toadd_dep
. Settable, if you want to remove dependencies or perform other changes.set_id
(
character(1)
)
ID of this param set. Default""
. Settable.length
(
integer(1)
)
Number of contained Params.is_empty
(
logical(1)
)
Is theParamSet
empty?class
(named
character()
)
Classes of contained parameters, named with parameter IDs.lower
(named
double()
)
Lower bounds of parameters (NA
if parameter is not numeric). Named with parameter IDs.upper
(named
double()
)
Upper bounds of parameters (NA
if parameter is not numeric). Named with parameter IDs.levels
(named
list()
)
List of character vectors of allowed categorical values of contained parameters.NULL
if the parameter is not categorical. Named with parameter IDs.nlevels
(named
integer()
)
Number of categorical levels per parameter,Inf
for double parameters or unbounded integer parameters. Named with param IDs.is_bounded
(named
logical()
)
Do all parameters have finite bounds? Named with parameter IDs.special_vals
(named
list()
oflist()
)
Special values for all parameters. Named with parameter IDs.default
(named
list()
)
Default values of all parameters. If no default exists, element is not present. Named with parameter IDs.tags
(named
list()
ofcharacter()
)
Can be used to group and subset parameters. Named with parameter IDs.storage_type
(
character()
)
Data types of parameters when stored in tables. Named with parameter IDs.is_number
(named
logical()
)
Position is TRUE for ParamDbl and ParamInt. Named with parameter IDs.is_categ
(named
logical()
)
Position is TRUE for ParamFct and ParamLgl. Named with parameter IDs.all_numeric
(
logical(1)
)
IsTRUE
if all parameters are ParamDbl or ParamInt.all_categorical
(
logical(1)
)
IsTRUE
if all parameters are ParamFct and ParamLgl.trafo
(
function(x, param_set)
)
Transformation function. Settable. User has to pass afunction(x, param_set)
, of the form
(namedlist()
, ParamSet) -> namedlist()
.
The function is responsible to transform a feasible configuration into another encoding, before potentially evaluating the configuration with the target algorithm. For the output, not many things have to hold. It needs to have unique names, and the target algorithm has to accept the configuration. For convenience, the self-paramset is also passed in, if you need some info from it (e.g. tags). Is NULL by default, and you can set it to NULL to switch the transformation off.has_trafo
(
logical(1)
)
Has the set atrafo
function?values
(named
list()
)
Currently set / fixed parameter values. Settable, and feasibility of values will be checked when you set them. You do not have to set values for all parameters, but only for a subset. When you set values, all previously set values will be unset / removed.has_deps
(
logical(1)
)
Has the set parameter dependencies?
Methods
Method add()
Adds a single param or another set to this set, all params are cloned.
Arguments
p
(Param | ParamSet).
Method ids()
Retrieves IDs of contained parameters based on some filter criteria
selections, NULL
means no restriction.
Only returns IDs of parameters that satisfy all conditions.
Arguments
class
(
character()
).is_bounded
(
logical(1)
).tags
(
character()
).
Method get_values()
Retrieves parameter values based on some selections, NULL
means no
restriction and is equivalent to $values
.
Only returns values of parameters that satisfy all conditions.
Usage
ParamSet$get_values(
class = NULL,
is_bounded = NULL,
tags = NULL,
type = "with_token",
check_required = TRUE
)
Arguments
class
(
character()
).is_bounded
(
logical(1)
).tags
(
character()
).type
(
character(1)
)
Return valueswith_token
,without_token
oronly_token
?check_required
(
logical(1)
)
Check if all required parameters are set?
Returns
Named list()
.
Method set_values()
Allows to to modify (and overwrite) or replace the parameter values. Per default already set values are being kept unless new values are being provided.
Usage
ParamSet$set_values(..., .values = list(), .insert = TRUE)
Arguments
...
(any)
Named parameter values..values
(named
list()
)
Named list with parameter values. Names must not already appear in...
..insert
(
logical(1)
)
Whether to insert the values (old values are being kept, if not overwritten), or to replace all values. Default is TRUE.
Method search_space()
Construct a ParamSet
to tune over. Constructed from TuneToken
in $values
, see to_tune()
.
Arguments
values
(
named list
): optional named list ofTuneToken
objects to convert, in place of$values
.
Method check()
checkmate-like check-function. Takes a named list.
A point x is feasible, if it configures a subset of params,
all individual param constraints are satisfied and all dependencies are satisfied.
Params for which dependencies are not satisfied should not be part of x
.
Arguments
xs
(named
list()
).
Method test()
checkmate-like test-function. Takes a named list.
A point x is feasible, if it configures a subset of params,
all individual param constraints are satisfied and all dependencies are satisfied.
Params for which dependencies are not satisfied should not be part of x
.
Arguments
xs
(named
list()
).
Method assert()
checkmate-like assert-function. Takes a named list.
A point x is feasible, if it configures a subset of params,
all individual param constraints are satisfied and all dependencies are satisfied.
Params for which dependencies are not satisfied should not be part of x
.
Method check_dt()
checkmate-like check-function. Takes a data.table::data.table
where rows are points and columns are parameters. A point x is feasible,
if it configures a subset of params, all individual param constraints are
satisfied and all dependencies are satisfied. Params for which
dependencies are not satisfied should be set to NA
in xdt
.
Method assert_dt()
checkmate-like assert-function (s. $check_dt()
).
Arguments
xdt
.var.name
(
character(1)
)
Name of the checked object to print in error messages.
Defaults to the heuristic implemented in vname.
Method add_dep()
Adds a dependency to this set, so that param id
now depends on param on
.
Arguments
id
(
character(1)
).on
(
character(1)
).cond
(Condition).
Method print()
Printer.
Usage
ParamSet$print(
...,
hide_cols = c("levels", "is_bounded", "special_vals", "tags", "storage_type")
)
Arguments
...
(ignored).
hide_cols
(
character()
)
Which fields should not be printed? Default is"levels"
,"is_bounded"
,"special_vals"
,"tags"
, and"storage_type"
.