Skip to content

Commit

Permalink
updates for no-suggests
Browse files Browse the repository at this point in the history
  • Loading branch information
topepo committed Oct 15, 2024
1 parent 4971046 commit 6b08f86
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 64 deletions.
61 changes: 31 additions & 30 deletions R/bagger.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,49 +44,50 @@
#' comparison of methods to study the contribution of variables in artificial
#' neural network models. Ecological Modelling, 160(3), 249-264.
#' @examples
#' library(recipes)
#' library(dplyr)
#' if (rlang::is_installed(c("recipes", "modeldata"))) {
#' library(recipes)
#' library(dplyr)
#'
#' data(biomass, package = "modeldata")
#' data(biomass, package = "modeldata")
#'
#' biomass_tr <-
#' biomass %>%
#' dplyr::filter(dataset == "Training") %>%
#' dplyr::select(-dataset, -sample)
#' biomass_tr <-
#' biomass %>%
#' dplyr::filter(dataset == "Training") %>%
#' dplyr::select(-dataset, -sample)
#'
#' biomass_te <-
#' biomass %>%
#' dplyr::filter(dataset == "Testing") %>%
#' dplyr::select(-dataset, -sample)
#' biomass_te <-
#' biomass %>%
#' dplyr::filter(dataset == "Testing") %>%
#' dplyr::select(-dataset, -sample)
#'
#' # ------------------------------------------------------------------------------
#' # ------------------------------------------------------------------------------
#'
#' ctrl <- control_bag(var_imp = TRUE)
#' ctrl <- control_bag(var_imp = TRUE)
#'
#' # ------------------------------------------------------------------------------
#' # ------------------------------------------------------------------------------
#'
#' # `times` is low to make the examples run faster
#' # `times` is low to make the examples run faster
#'
#'
#' set.seed(7687)
#' cart_bag <- bagger(x = biomass_tr[, -6], y = biomass_tr$HHV,
#' base_model = "CART", times = 5, control = ctrl)
#' cart_bag
#'
#' # ------------------------------------------------------------------------------
#' # Other interfaces
#' set.seed(7687)
#' cart_bag <- bagger(x = biomass_tr[, -6], y = biomass_tr$HHV,
#' base_model = "CART", times = 5, control = ctrl)
#' cart_bag
#'
#' # Recipes can be used
#' biomass_rec <-
#' recipe(HHV ~ ., data = biomass_tr) %>%
#' step_pca(all_predictors())
#' # ------------------------------------------------------------------------------
#' # Other interfaces
#'
#' set.seed(7687)
#' cart_pca_bag <- bagger(biomass_rec, data = biomass_tr, base_model = "CART",
#' times = 5, control = ctrl)
#' # Recipes can be used
#' biomass_rec <-
#' recipe(HHV ~ ., data = biomass_tr) %>%
#' step_pca(all_predictors())
#'
#' cart_pca_bag
#' set.seed(7687)
#' cart_pca_bag <- bagger(biomass_rec, data = biomass_tr, base_model = "CART",
#' times = 5, control = ctrl)
#'
#' cart_pca_bag
#' }
#' @export
bagger <- function(x, ...) {
UseMethod("bagger")
Expand Down
61 changes: 31 additions & 30 deletions man/bagger.Rd

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

13 changes: 9 additions & 4 deletions tests/testthat/helper-baguette.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
library(rlang)
library(purrr)
library(yardstick)
library(recipes)

data("two_class_dat", package = "modeldata")
if (is_installed("yardstick")) {
library(yardstick)
}
if (is_installed("recipes")) {
library(recipes)
}
if (is_installed("modeldata")) {
data("two_class_dat", package = "modeldata")
}

# ------------------------------------------------------------------------------

Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-interfaces.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
test_that('recipe execution', {
skip_if_not_installed("recipes")

# check to make sure that prepped data are given to model
rec <-
recipe(Sepal.Length ~ ., data = iris) %>%
Expand Down

0 comments on commit 6b08f86

Please sign in to comment.