Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new parameters for tidymodels/embed#213 #324

Merged
merged 6 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export(grid_regular)
export(harmonic_frequency)
export(has_unknowns)
export(hidden_units)
export(initial_umap)
export(is_unknown)
export(kernel_offset)
export(learn_rate)
Expand Down Expand Up @@ -172,6 +173,7 @@ export(summary_stat)
export(surv_dist)
export(survival_link)
export(svm_margin)
export(target_weight)
export(threshold)
export(token)
export(tree_depth)
Expand All @@ -189,6 +191,7 @@ export(value_set)
export(value_transform)
export(value_validate)
export(values_activation)
export(values_initial_umap)
export(values_prune_method)
export(values_regularization_method)
export(values_scheduler)
Expand Down
29 changes: 29 additions & 0 deletions R/param_initial_umap.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#' Initialization method for UMAP
#'
#' This parameter is the type of initialization for the UMAP coordinates. Can be
#' one of `"spectral"`, `"normlaplacian"`, `"random"`, `"lvrandom"`,
#' `"laplacian"`, `"pca"`, `"spca"`, or `"agspectral"`.See [uwot::umap()] for
hfrick marked this conversation as resolved.
Show resolved Hide resolved
#' more details.
#'
#' @param values A character string of possible values. See `values_initial_umap`
#' in examples below.
#'
#' @details
#' This parameter is used in `recipes` via [embed::step_umap()].
#' @examples
#' values_initial_umap
#' initial_umap()
#' @export
initial_umap <- function(values = values_initial_umap) {
new_qual_param(
type = "character",
values = values,
label = c(initial_umap = "UMAP Initialization"),
finalize = NULL
)
}

#' @rdname initial_umap
#' @export
values_initial_umap <- c("spectral", "normlaplacian", "random", "lvrandom",
"laplacian", "pca", "spca", "agspectral")
21 changes: 21 additions & 0 deletions R/param_target_weight.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#' Amount of supervision parameter
#'
#' For [uwot::umap()] and [embed::step_umap()], this is a weighting factor
#' between data topology and target topology. A value of 0.0 weights entirely
#' on data, a value of 1.0 weights entirely on target. The default of 0.5
#' balances the weighting equally between data and target.
#'
hfrick marked this conversation as resolved.
Show resolved Hide resolved
#' @inheritParams Laplace
#' @examples
#' target_weight()
#' @export
target_weight <- function(range = c(0, 1), trans = NULL) {
new_quant_param(
type = "double",
range = range,
inclusive = c(TRUE, FALSE),
trans = trans,
label = c(target_weight = "Proportion Supervised"),
finalize = NULL
)
}
2 changes: 2 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ reference:
- extrapolation
- freq_cut
- harmonic_frequency
- initial_umap
- Laplace
- learn_rate
- max_nodes
Expand Down Expand Up @@ -93,6 +94,7 @@ reference:
- summary_stat
- surv_dist
- survival_link
- target_weight
- threshold
- token
- trees
Expand Down
33 changes: 33 additions & 0 deletions man/initial_umap.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions man/target_weight.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions tests/testthat/test-params.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ test_that("param ranges", {
expect_equal(num_runs(c(2, 100))$range, list(lower = 2, upper = 100))
expect_equal(harmonic_frequency(c(2, 100))$range, list(lower = 2, upper = 100))
expect_equal(validation_set_prop(c(0.1, 0.4))$range, list(lower = 0.1, upper = 0.4))
expect_equal(target_weight(c(0.1, 0.4))$range, list(lower = 0.1, upper = 0.4))
})


Expand All @@ -107,4 +108,5 @@ test_that("param values", {
expect_equal(survival_link()$values, values_survival_link)
expect_equal(activation()$values, values_activation)
expect_equal(rate_schedule()$values, values_scheduler)
expect_equal(initial_umap()$values, values_initial_umap)
})
Loading