Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

* `prop_terms()` is a new parameter object used for recipes that do supervised feature selection (#395).

* `batch_size()` now has a specific default parameter range instead of an unknown default range. `get_batch_sizes()` is deprecated (#398).

# dials 1.4.1

* Two new parameters, `cal_method_class()` and `cal_method_reg(),` to control which method is used to calibrate model predictions (#383).
Expand Down
9 changes: 8 additions & 1 deletion R/finalize.R
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,16 @@ get_rbf_range <- function(object, x, seed = sample.int(10^5, 1), ...) {
range_set(object, rng)
}

#' Get batch sizes
#'
#' `r lifecycle::badge("deprecated")`
#'
#' @inheritParams finalize
#' @keywords internal
#' @export
#' @rdname finalize
get_batch_sizes <- function(object, x, frac = c(1 / 10, 1 / 3), ...) {
lifecycle::deprecate_warn("1.4.2", "get_batch_sizes()")

rngs <- range_get(object, original = FALSE)
if (!is_unknown(rngs$lower) & !is_unknown(rngs$upper)) {
return(object)
Expand Down
4 changes: 2 additions & 2 deletions R/param_network.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ hidden_units_2 <- function(range = c(1L, 10L), trans = NULL) {
#' @export
#' @rdname dropout
batch_size <- function(
range = c(unknown(), unknown()),
range = c(2L, 7L),
trans = transform_log2()
) {
new_quant_param(
Expand All @@ -76,6 +76,6 @@ batch_size <- function(
inclusive = c(TRUE, TRUE),
trans = trans,
label = c(batch_size = "Batch Size"),
finalize = get_batch_sizes
finalize = NULL
)
}
2 changes: 1 addition & 1 deletion man/dropout.Rd

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

3 changes: 0 additions & 3 deletions man/finalize.Rd

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

26 changes: 26 additions & 0 deletions man/get_batch_sizes.Rd

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

8 changes: 8 additions & 0 deletions tests/testthat/_snaps/finalize.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@
Error in `get_n_frac()`:
! Cannot determine number of columns. Is `x` a 2D data object?

# `get_batch_size() is deprecated

Code
bsizes <- get_batch_sizes(batch_size(), iris, frac = c(0.3, 0.7))
Condition
Warning:
`get_batch_sizes()` was deprecated in dials 1.4.2.

# estimate sigma

Code
Expand Down
27 changes: 24 additions & 3 deletions tests/testthat/test-finalize.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,33 @@ test_that("estimate rows", {
list(lower = 16, upper = 37)
)

expect_equal(get_n_frac(mtry(c(1, 2)), mtcars), mtry(c(1, 2)))
})

test_that("`get_batch_size() is deprecated", {
expect_snapshot(
bsizes <- get_batch_sizes(batch_size(), iris, frac = c(.3, .7))
)
})

test_that("`get_batch_size() works", {
withr::local_options(lifecycle_verbosity = "quiet")
mock_batch_size_with_unknown <- new_quant_param(
type = "integer",
range = c(unknown(), unknown()),
inclusive = c(TRUE, TRUE),
trans = transform_log2(),
label = c(batch_size = "Batch Size"),
finalize = get_batch_sizes
)
expect_equal(
get_batch_sizes(batch_size(), iris, frac = c(.3, .7))$range,
get_batch_sizes(
mock_batch_size_with_unknown,
iris,
frac = c(.3, .7)
)$range,
list(lower = log2(45), upper = log2(105))
)

expect_equal(get_n_frac(mtry(c(1, 2)), mtcars), mtry(c(1, 2)))
})


Expand Down
Loading