diff --git a/R/Domain.R b/R/Domain.R index 5183af66..8a6ddd31 100644 --- a/R/Domain.R +++ b/R/Domain.R @@ -68,7 +68,7 @@ #' Function with one argument, which is a list of parameter values and that returns the aggregated parameter value. #' @param in_tune_fn (`function(domain, param_vals)`)\cr #' Function that converters a `Domain` object into a parameter value. -#' Can onlye be given for parameters tagged with `"internal_tuning"`. +#' Can only be given for parameters tagged with `"internal_tuning"`. #' This function should also assert that the parameters required to enable internal tuning for the given `domain` are #' set in `param_vals` (such as `early_stopping_rounds` for `XGBoost`). #' @param disable_in_tune (named `list()`)\cr @@ -133,17 +133,25 @@ #' #' param_set = ps( #' iters = p_int(0, Inf, tags = "internal_tuning", aggr = function(x) round(mean(unlist(x))), -#' in_tune_fn = function(domain, param_vals) domain$upper, -#' disable_in_tune = list(other_param = FALSE)) +#' in_tune_fn = function(domain, param_vals) { +#' stopifnot(domain$lower <= 1) +#' stopifnot(param_vals$early_stopping == TRUE) +#' domain$upper +#' }, +#' disable_in_tune = list(early_stopping = FALSE)), +#' early_stopping = p_lgl() #' ) #' param_set$set_values( -#' iters = to_tune(upper = 100, internal = TRUE) +#' iters = to_tune(upper = 100, internal = TRUE), +#' early_stopping = TRUE #' ) #' param_set$convert_internal_search_space(param_set$search_space()) #' param_set$aggr_internal_tuned_values( #' list(iters = list(1, 2, 3)) #' ) #' +#' param_set$disable_internal_tuning("iters") +#' param_set$values$early_stopping #' @family ParamSet construction helpers #' @name Domain NULL diff --git a/man/Domain.Rd b/man/Domain.Rd index e63cc3ec..48c4e42f 100644 --- a/man/Domain.Rd +++ b/man/Domain.Rd @@ -158,9 +158,11 @@ value upon construction.} Default aggregation function for a parameter. Can only be given for parameters tagged with \code{"internal_tuning"}. Function with one argument, which is a list of parameter values and that returns the aggregated parameter value.} -\item{in_tune_fn}{(\verb{function(domain, param_set)})\cr +\item{in_tune_fn}{(\verb{function(domain, param_vals)})\cr Function that converters a \code{Domain} object into a parameter value. -Can onlye be given for parameters tagged with \code{"internal_tuning"}.} +Can only be given for parameters tagged with \code{"internal_tuning"}. +This function should also assert that the parameters required to enable internal tuning for the given \code{domain} are +set in \code{param_vals} (such as \code{early_stopping_rounds} for \code{XGBoost}).} \item{disable_in_tune}{(named \code{list()})\cr The parameter values that need to be set in the \code{ParamSet} to disable the internal tuning for the parameter. @@ -254,15 +256,25 @@ print(grid$transpose()) param_set = ps( iters = p_int(0, Inf, tags = "internal_tuning", aggr = function(x) round(mean(unlist(x))), - in_tune_fn = function(domain, param_set) domain$upper, - disable_in_tune = list(other_param = FALSE)) + in_tune_fn = function(domain, param_vals) { + stopifnot(domain$lower <= 1) + stopifnot(param_vals$early_stopping == TRUE) + domain$upper + }, + disable_in_tune = list(early_stopping = FALSE)), + early_stopping = p_lgl() ) param_set$set_values( - iters = to_tune(upper = 100, internal = TRUE) + iters = to_tune(upper = 100, internal = TRUE), + early_stopping = TRUE ) param_set$convert_internal_search_space(param_set$search_space()) -param_set$aggr(list(iters = list(1, 2, 3))) +param_set$aggr_internal_tuned_values( + list(iters = list(1, 2, 3)) +) +param_set$disable_internal_tuning("iters") +param_set$values$early_stopping } \seealso{ Other ParamSet construction helpers: diff --git a/man/ParamSet.Rd b/man/ParamSet.Rd index e4cc954f..a4ad34e7 100644 --- a/man/ParamSet.Rd +++ b/man/ParamSet.Rd @@ -172,7 +172,7 @@ Named with param IDs.} \item \href{#method-ParamSet-get_values}{\code{ParamSet$get_values()}} \item \href{#method-ParamSet-set_values}{\code{ParamSet$set_values()}} \item \href{#method-ParamSet-trafo}{\code{ParamSet$trafo()}} -\item \href{#method-ParamSet-aggr}{\code{ParamSet$aggr()}} +\item \href{#method-ParamSet-aggr_internal_tuned_values}{\code{ParamSet$aggr_internal_tuned_values()}} \item \href{#method-ParamSet-disable_internal_tuning}{\code{ParamSet$disable_internal_tuning()}} \item \href{#method-ParamSet-convert_internal_search_space}{\code{ParamSet$convert_internal_search_space()}} \item \href{#method-ParamSet-test_constraint}{\code{ParamSet$test_constraint()}} @@ -343,12 +343,12 @@ In almost all cases, the default \code{param_set = self} should be used.} } } \if{html}{\out{
paradox::ParamSet$add_dep()
paradox::ParamSet$aggr()
paradox::ParamSet$aggr_internal_tuned_values()
paradox::ParamSet$assert()
paradox::ParamSet$assert_dt()
paradox::ParamSet$check()
paradox::ParamSet$check_dependencies()
paradox::ParamSet$check_dt()
paradox::ParamSet$convert_internal_search_space()
paradox::ParamSet$flatten()
paradox::ParamSet$format()
paradox::ParamSet$get_domain()
paradox::ParamSet$get_values()