Learn R Programming

paradox (version 0.3.0)

Param: Param Class

Description

This is the abstract base class for parameter objects like ParamDbl and ParamFct.

Arguments

S3 methods

Public fields

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.

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 of special_vals. Has value NO_DEF if no default exists. NULL can be a valid default.

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.

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 error message.

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

ParamSet.

Method format()

Helper for print outputs.

Usage

Param$format()

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 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