diff --git a/NAMESPACE b/NAMESPACE index eab05813..855fb94a 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -55,6 +55,7 @@ export(batch_size) export(buffer) export(cal_method_class) export(cal_method_reg) +export(circular) export(class_weights) export(conditional_min_criterion) export(conditional_test_statistic) @@ -105,6 +106,7 @@ export(max_times) export(max_tokens) export(min_dist) export(min_n) +export(min_points) export(min_times) export(min_unique) export(mixture) @@ -142,6 +144,7 @@ export(prior_terminal_node_expo) export(prod_degree) export(prune) export(prune_method) +export(radius) export(range_get) export(range_set) export(range_validate) @@ -165,6 +168,9 @@ export(sample_size) export(scale_factor) export(scale_pos_weight) export(select_features) +export(shared_orientation) +export(shared_shape) +export(shared_size) export(shrinkage_correlation) export(shrinkage_frequencies) export(shrinkage_variance) @@ -216,6 +222,7 @@ export(weight) export(weight_func) export(weight_scheme) export(window_size) +export(zero_covariance) import(rlang) importFrom(DiceDesign,dmaxDesign) importFrom(DiceDesign,lhsDesign) diff --git a/R/param_engine_dbscan.R b/R/param_engine_dbscan.R new file mode 100644 index 00000000..316aaaf5 --- /dev/null +++ b/R/param_engine_dbscan.R @@ -0,0 +1,40 @@ +#' Parameters for possible engine parameters for dbscan +#' +#' These parameters are used for density-based clustering methods that use the +#' dbscan engine. They correspond to tuning parameters that would be specified using +#' `set_engine("dbscan", ...)`. +#' +#' @inheritParams Laplace +#' @details +#' To use these, check `?tidyclust::db_clust` to see how they are used. +#' - `radius()` controls the radius used to determine core-points and cluster assignments +#' - `min_points()` controls the minimum number of nearby points to be considered a core-point (including the point itself) +#' +#' @examples +#' radius() +#' min_points() +#' @rdname dbscan_parameters +#' @export +radius <- function(range = c(-2, 2), trans = transform_log10()) { + new_quant_param( + type = "double", + range = range, + inclusive = c(TRUE, TRUE), + trans = trans, + label = c(radius = "Radius"), + finalize = NULL + ) +} + +#' @export +#' @rdname dbscan_parameters +min_points <- function(range = c(3L, 50L), trans = NULL) { + new_quant_param( + type = "integer", + range = range, + inclusive = c(TRUE, TRUE), + trans = trans, + label = c(min_points = "Minimum Points Threshold"), + finalize = NULL + ) +} diff --git a/R/param_engine_mclust.R b/R/param_engine_mclust.R new file mode 100644 index 00000000..c3be5c1a --- /dev/null +++ b/R/param_engine_mclust.R @@ -0,0 +1,73 @@ +#' Parameters for possible engine parameters for mclust +#' +#' These parameters are used for fitting Gaussian mixture models that use the +#' mclust engine. They correspond to tuning parameters that would be specified using +#' `set_engine("mclust", ...)`. +#' +#' @param values For `circular()`, `zero_covariance()`, +#' `shared_orientation()`, `shared_shape()`, and `shared_size()` either `TRUE` or `FALSE`. +#' @details +#' To use these, check `?tidyclust::gm_clust` to see how they are used. +#' @examples +#' circular() +#' zero_covariance() +#' shared_orientation() +#' shared_shape() +#' shared_size() +#' @rdname mclust_parameters +#' @export +circular <- function(values = c(TRUE, FALSE)) { + new_qual_param( + type = "logical", + values = values, + label = c(circular = "Circular cluster shapes?"), + finalize = NULL + ) +} + + +#' @export +#' @rdname mclust_parameters +zero_covariance <- function(values = c(TRUE, FALSE)) { + new_qual_param( + type = "logical", + values = values, + label = c(zero_covariance = "Zero covariance between predictors?"), + finalize = NULL + ) +} + +#' @export +#' @rdname mclust_parameters +shared_orientation <- function(values = c(TRUE, FALSE)) { + new_qual_param( + type = "logical", + values = values, + label = c(shared_orientation = "Shared orientation between clusters?"), + finalize = NULL + ) +} + +#' @export +#' @rdname mclust_parameters +shared_shape <- function(values = c(TRUE, FALSE)) { + new_qual_param( + type = "logical", + values = values, + label = c(shared_shape = "Same shape for all clusters?"), + finalize = NULL + ) +} + + +#' @export +#' @rdname mclust_parameters +shared_size <- function(values = c(TRUE, FALSE)) { + new_qual_param( + type = "logical", + values = values, + label = c(shared_size = "Same size for all clusters?"), + finalize = NULL + ) +} + diff --git a/_pkgdown.yml b/_pkgdown.yml index 9ab8a7e9..280da31c 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -101,16 +101,23 @@ reference: - title: Parameter objects for specific model engines contents: - bart-param + - circular - conditional_min_criterion - confidence_factor - extrapolation - max_nodes - max_num_terms + - min_points - num_leaves + - radius - regularization_factor - rule_bands - scale_pos_weight + - shared_orientation + - shared_shape + - shared_size - shrinkage_correlation + - zero_covariance - title: Parameter objects for post-processing contents: diff --git a/man/dbscan_parameters.Rd b/man/dbscan_parameters.Rd new file mode 100644 index 00000000..d8059707 --- /dev/null +++ b/man/dbscan_parameters.Rd @@ -0,0 +1,37 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/param_engine_dbscan.R +\name{radius} +\alias{radius} +\alias{min_points} +\title{Parameters for possible engine parameters for dbscan} +\usage{ +radius(range = c(-2, 2), trans = transform_log10()) + +min_points(range = c(3L, 50L), trans = NULL) +} +\arguments{ +\item{range}{A two-element vector holding the \emph{defaults} for the smallest and +largest possible values, respectively. If a transformation is specified, +these values should be in the \emph{transformed units}.} + +\item{trans}{A \code{trans} object from the \code{scales} package, such as +\code{scales::transform_log10()} or \code{scales::transform_reciprocal()}. If not provided, +the default is used which matches the units used in \code{range}. If no +transformation, \code{NULL}.} +} +\description{ +These parameters are used for density-based clustering methods that use the +dbscan engine. They correspond to tuning parameters that would be specified using +\code{set_engine("dbscan", ...)}. +} +\details{ +To use these, check \code{?tidyclust::db_clust} to see how they are used. +\itemize{ +\item \code{radius()} controls the radius used to determine core-points and cluster assignments +\item \code{min_points()} controls the minimum number of nearby points to be considered a core-point (including the point itself) +} +} +\examples{ +radius() +min_points() +} diff --git a/man/dials-package.Rd b/man/dials-package.Rd index 64667afe..e55736d9 100644 --- a/man/dials-package.Rd +++ b/man/dials-package.Rd @@ -53,7 +53,7 @@ Authors: Other contributors: \itemize{ - \item Posit Software, PBC (\href{https://ror.org/03wc8by49}{ROR}) [copyright holder, funder] + \item Posit Software, PBC (03wc8by49) [copyright holder, funder] } } diff --git a/man/mclust_parameters.Rd b/man/mclust_parameters.Rd new file mode 100644 index 00000000..adae8606 --- /dev/null +++ b/man/mclust_parameters.Rd @@ -0,0 +1,39 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/param_engine_mclust.R +\name{circular} +\alias{circular} +\alias{zero_covariance} +\alias{shared_orientation} +\alias{shared_shape} +\alias{shared_size} +\title{Parameters for possible engine parameters for mclust} +\usage{ +circular(values = c(TRUE, FALSE)) + +zero_covariance(values = c(TRUE, FALSE)) + +shared_orientation(values = c(TRUE, FALSE)) + +shared_shape(values = c(TRUE, FALSE)) + +shared_size(values = c(TRUE, FALSE)) +} +\arguments{ +\item{values}{For \code{circular()}, \code{zero_covariance()}, +\code{shared_orientation()}, \code{shared_shape()}, and \code{shared_size()} either \code{TRUE} or \code{FALSE}.} +} +\description{ +These parameters are used for fitting Gaussian mixture models that use the +mclust engine. They correspond to tuning parameters that would be specified using +\code{set_engine("mclust", ...)}. +} +\details{ +To use these, check \code{?tidyclust::gm_clust} to see how they are used. +} +\examples{ +circular() +zero_covariance() +shared_orientation() +shared_shape() +shared_size() +} diff --git a/tests/testthat/test-params.R b/tests/testthat/test-params.R index b71f5c41..480810f0 100644 --- a/tests/testthat/test-params.R +++ b/tests/testthat/test-params.R @@ -137,11 +137,13 @@ test_that("param ranges", { expect_equal(target_weight(c(0.1, 0.4))$range, list(lower = 0.1, upper = 0.4)) expect_equal(lower_limit(c(Inf, 0))$range, list(lower = Inf, upper = 0)) expect_equal(upper_limit(c(0, Inf))$range, list(lower = 0, upper = Inf)) - expect_equal(max_num_terms(c(31, 100))$range, list(lower = 31, upper = 100)) - expect_equal(max_nodes(c(31, 100))$range, list(lower = 31, upper = 100)) - expect_equal(num_tokens(c(31, 100))$range, list(lower = 31, upper = 100)) - expect_equal(mtry_prop(c(.1, .2))$range, list(lower = .1, upper = .2)) - expect_equal(dropout(c(.1, .2))$range, list(lower = .1, upper = .2)) + expect_equal(max_num_terms(c(31,100))$range, list(lower = 31, upper = 100)) + expect_equal(max_nodes(c(31,100))$range, list(lower = 31, upper = 100)) + expect_equal(num_tokens(c(31,100))$range, list(lower = 31, upper = 100)) + expect_equal(mtry_prop(c(.1,.2))$range, list(lower = .1, upper = .2)) + expect_equal(dropout(c(.1,.2))$range, list(lower = .1, upper = .2)) + expect_equal(radius(c(0.01, 100))$range, list(lower = 0.01, upper = 100)) + expect_equal(min_points(c(3, 50))$range, list(lower = 3, upper = 50)) }) @@ -178,4 +180,9 @@ test_that("param values", { expect_equal(all_neighbors(TRUE)$values, TRUE) expect_equal(cal_method_class()$values, values_cal_cls) expect_equal(cal_method_reg()$values, values_cal_reg) + expect_equal(circular(TRUE)$values, TRUE) + expect_equal(zero_covariance(TRUE)$values, TRUE) + expect_equal(shared_orientation(TRUE)$values, TRUE) + expect_equal(shared_shape(TRUE)$values, TRUE) + expect_equal(shared_size(TRUE)$values, TRUE) })