diff --git a/R/parameters.R b/R/parameters.R index 50e11e20..55ab7da9 100644 --- a/R/parameters.R +++ b/R/parameters.R @@ -1,9 +1,22 @@ -#' Information on tuning parameters within an object +#' Create a parameter set #' #' @param x An object, such as a list of `param` objects or an actual `param` -#' object. +#' object. #' @param ... Only used for the `param` method so that multiple `param` objects -#' can be passed to the function. +#' can be passed to the function. +#' +#' @return +#' A parameter set of class `parameters` in the form of a data frame where each +#' row represents one tunable parameter. +#' +#' @seealso [dials::update.parameters()], [dials::finalize()], +#' [hardhat::extract_parameter_set_dials()] +#' +#' @examples +#' params <- list(lambda = penalty(), alpha = mixture(), `rand forest` = mtry()) +#' pset <- parameters(params) +#' pset +#' #' @export parameters <- function(x, ...) { UseMethod("parameters") @@ -177,12 +190,13 @@ print.parameters <- function(x, ...) { print_x$object <- purrr::map_chr( print_x$object, - \(.x) + \(.x) { if (all(is.na(.x))) { "missing" } else { pillar::type_sum(.x) } + } ) cli::cli_par() diff --git a/man/parameters.Rd b/man/parameters.Rd index 289307ea..81a80028 100644 --- a/man/parameters.Rd +++ b/man/parameters.Rd @@ -5,7 +5,7 @@ \alias{parameters.default} \alias{parameters.param} \alias{parameters.list} -\title{Information on tuning parameters within an object} +\title{Create a parameter set} \usage{ parameters(x, ...) @@ -22,6 +22,20 @@ object.} \item{...}{Only used for the \code{param} method so that multiple \code{param} objects can be passed to the function.} } +\value{ +A parameter set of class \code{parameters} in the form of a data frame where each +row represents one tunable parameter. +} \description{ -Information on tuning parameters within an object +Create a parameter set +} +\examples{ +params <- list(lambda = penalty(), alpha = mixture(), `rand forest` = mtry()) +pset <- parameters(params) +pset + +} +\seealso{ +\code{\link[=update.parameters]{update.parameters()}}, \code{\link[=finalize]{finalize()}}, +\code{\link[hardhat:hardhat-extract]{hardhat::extract_parameter_set_dials()}} }