paradox
paradox copied to clipboard
sugar for trafos and composition of trafos
see this here, simply for rounding all doubles to ints (for tuners which need this) or doing 2^x, etc
ps = ParamSet$new(params = list(
ParamDbl$new("cp", lower = 0.001, upper = 0.1),
ParamInt$new("minsplit", lower = 1, upper = 10)
))
ps$trafo = function(x, param_set) {
cl = param_set$class
for (n in names(x)) {
if (cl[n] == "ParamInt")
x[[n]] = round(x[[n]])
}
return(x)
}
wouldnt it be nice to have some simple shorthand function which do common operations? and which are composable (which they are as they are functions)
so
ps$trafo = round_int("minsplit") %>% log_scale("cp") ? or similar?
@mllg @mb706 @jakob-r
or don think this is very hard to do, each is a 2-5 liner
of course I always forget that base R doesnt have a "compose" function and i dont want to import the Funtional-package for this... :(
For quick type conversion specifically you could vectorize the as function?
I've included as.list to ensure each can take a different class.
A similar argument could be used for other quick coercions
y = data.frame(c(1.1,2.2,3.3), c(“integer”,“logical”,“complex”), stringsAsFactors = FALSE)
z <- Vectorize(function(x, y) as.list(as(x,y)))
z(y[,1], y[,2])
ps %>%
add_trafo(round, c("minsplit", "other_param")) %>%
add_trafo(exp, c("cp", "yet_another_param"))
Do we still want that? Since we can now do this
search_space = ps(
minsplit = p_dbl(lower = 1, upper = 10, , trafo = round)
)
generate_design_grid(search_space, 3)$transpose()
I think we can close @mb706 ?
i would like to keep this open at least one engine call, so we can discuss it together