Skip to content

Commit

Permalink
Merge pull request #259 from tidymodels/num_clusters
Browse files Browse the repository at this point in the history
add `num_clusters()` param
  • Loading branch information
hfrick authored Nov 2, 2022
2 parents 3c0d53f + d2c497f commit d47dc47
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export(new_qual_param)
export(new_quant_param)
export(no_global_pruning)
export(num_breaks)
export(num_clusters)
export(num_comp)
export(num_hash)
export(num_knots)
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

* The label for `spline_degree()` was improved.

* Added `num_clusters()` for tidyclust models.

# dials 1.0.0

* The new parameter `mtry_prop()` is a variation on `mtry()` where the value is
Expand Down
18 changes: 18 additions & 0 deletions R/param_num_clusters.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#' Number of Clusters
#'
#' Used in most `tidyclust` models.
#'
#' @inheritParams Laplace
#' @examples
#' num_clusters()
#' @export
num_clusters <- function(range = c(1L, 10L), trans = NULL) {
new_quant_param(
type = "integer",
range = range,
inclusive = c(TRUE, TRUE),
trans = trans,
label = c(num_clusters = "# Clusters"),
finalize = NULL
)
}
1 change: 1 addition & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ reference:
- mtry_prop
- neighbors
- num_breaks
- num_clusters
- num_comp
- num_hash
- num_knots
Expand Down
24 changes: 24 additions & 0 deletions man/num_clusters.Rd

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

1 change: 1 addition & 0 deletions tests/testthat/test-params.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ test_that("param ranges", {
expect_equal(rate_steps(c(7L, 15L))$range, list(lower = 7L, upper = 15L))
expect_equal(rate_step_size(c(7L, 15L))$range, list(lower = 7L, upper = 15L))
expect_equal(rate_decay(c(1, 2))$range, list(lower = 1, upper = 2))
expect_equal(num_clusters(c(1, 2))$range, list(lower = 1, upper = 2))
})


Expand Down

0 comments on commit d47dc47

Please sign in to comment.