Package website: release | dev
Universal Parameter Space Description and Tools.
set.seed(123) knitr::opts_chunk$set(cache = FALSE, collapse = TRUE, comment = "#>") options(datatable.print.class = FALSE, datatable.print.keys = FALSE) library(paradox)
remotes::install_github("mlr-org/paradox")
Create a simple ParamSet using all supported Parameter Types:
"int"
)"dbl"
)TRUE
or FALSE
("lgl"
)"fct"
)ps = ParamSet$new( params = list( ParamInt$new(id = "z", lower = 1, upper = 3), ParamDbl$new(id = "x", lower = -10, upper = 10), ParamLgl$new(id = "flag"), ParamFct$new(id = "methods", levels = c("a","b","c")) ) )
Draw random samples / create random design:
generate_design_random(ps, 3)
Generate LHS Design:
requireNamespace("lhs") generate_design_lhs(ps, 3)
Generate Grid Design:
generate_design_grid(ps, resolution = 2)
Properties of the parameters within the ParamSet
:
ps$ids() ps$levels ps$nlevels ps$is_number ps$lower ps$upper
Check that a parameter satisfies all conditions of a ParamSet
, using $test()
(returns FALSE
on mismatch), $check()
(returns error description on mismatch), and $assert()
(throws error on mismatch):
ps$test(list(z = 1, x = 1)) ps$test(list(z = -1, x = 1)) ps$check(list(z = -1, x = 1)) ps$assert(list(z = -1, x = 1))
Transformations are functions with a fixed signature.
x
A named list of parameter valuesparam_set
the ParamSet
used to create the designTransformations can be used to change the distributions of sampled parameters. For example, to sample values between $2^-3$ and $2^3$ in a $log_2$-uniform distribution, one can sample uniformly between -3 and 3 and exponentiate the random value inside the transformation.
ps = ParamSet$new( params = list( ParamInt$new(id = "z", lower = -3, upper = 3), ParamDbl$new(id = "x", lower = 0, upper = 1) ) ) ps$trafo = function(x, param_set) { x$z = 2^x$z return(x) } ps_smplr = SamplerUnif$new(ps) x = ps_smplr$sample(2) xst = x$transpose() xst
Further documentation can be found in the mlr3book.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.