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{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-ParamSet-aggr}{}}} -\subsection{Method \code{aggr()}}{ +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-ParamSet-aggr_internal_tuned_values}{}}} +\subsection{Method \code{aggr_internal_tuned_values()}}{ Aggregate parameter values according to their aggregation rules. \subsection{Usage}{ -\if{html}{\out{
}}\preformatted{ParamSet$aggr(x)}\if{html}{\out{
}} +\if{html}{\out{
}}\preformatted{ParamSet$aggr_internal_tuned_values(x)}\if{html}{\out{
}} } \subsection{Arguments}{ diff --git a/man/ParamSetCollection.Rd b/man/ParamSetCollection.Rd index a1999df6..01c10e7f 100644 --- a/man/ParamSetCollection.Rd +++ b/man/ParamSetCollection.Rd @@ -73,6 +73,8 @@ This field provides direct references to the \code{\link{ParamSet}} objects.} \item \href{#method-ParamSetCollection-new}{\code{ParamSetCollection$new()}} \item \href{#method-ParamSetCollection-add}{\code{ParamSetCollection$add()}} \item \href{#method-ParamSetCollection-disable_internal_tuning}{\code{ParamSetCollection$disable_internal_tuning()}} +\item \href{#method-ParamSetCollection-convert_internal_search_space}{\code{ParamSetCollection$convert_internal_search_space()}} +\item \href{#method-ParamSetCollection-flatten}{\code{ParamSetCollection$flatten()}} \item \href{#method-ParamSetCollection-clone}{\code{ParamSetCollection$clone()}} } } @@ -80,14 +82,12 @@ This field provides direct references to the \code{\link{ParamSet}} objects.}
Inherited methods