diff --git a/pkg/caret/tests/testthat/test_misc.R b/pkg/caret/tests/testthat/test_misc.R index f5bcddd4..13d7548b 100644 --- a/pkg/caret/tests/testthat/test_misc.R +++ b/pkg/caret/tests/testthat/test_misc.R @@ -14,6 +14,9 @@ test_that("R2 and RMSE are calculating correctly", { test_that("auc calculation is > .5 when Xs provide prediction", { + skip_if_not_installed("MLmetrics") + skip_if_not_installed("earth") + skip_if_not_installed("mda") trCntlListMulti <- trainControl( diff --git a/pkg/caret/tests/testthat/test_multiclassSummary.R b/pkg/caret/tests/testthat/test_multiclassSummary.R index f79f2653..81bfb519 100644 --- a/pkg/caret/tests/testthat/test_multiclassSummary.R +++ b/pkg/caret/tests/testthat/test_multiclassSummary.R @@ -1,6 +1,7 @@ context('multiClassSummary') test_that("multiClassSummary presenting warnings from train", { + skip_if_not_installed("MLmetrics") skip_if_not_installed("ModelMetrics", "1.2.2.2") library(caret) N = 1000 @@ -38,6 +39,7 @@ test_that("multiClassSummary presenting warnings from train", { }) test_that("multiClassSummary ROC values", { + skip_if_not_installed("MLmetrics") lvls <- levels(iris$Species) set.seed(46337) diff --git a/pkg/caret/tests/testthat/test_preProcess_methods.R b/pkg/caret/tests/testthat/test_preProcess_methods.R index 4479e25f..9d7036a0 100644 --- a/pkg/caret/tests/testthat/test_preProcess_methods.R +++ b/pkg/caret/tests/testthat/test_preProcess_methods.R @@ -1,8 +1,3 @@ -library(caret) -library(fastICA) -library(testthat) -library(MASS) - context('preProcess/methods') ################################################################### @@ -186,6 +181,7 @@ test_that('issue #825 for pca threshold choice', { ## test ica test_that('ICA trans', { + skip_if_not_installed("fastICA") skip_on_cran() set.seed(1) ica_dat1 <- twoClassSim(30)[, 1:5] @@ -202,8 +198,7 @@ test_that('ICA trans', { ica_dat2_scaled[,i] <- (ica_dat2_scaled[,i]-ica_dat1_means[i])/ica_dat1_sds[i] set.seed(1) - ic_obj <- fastICA(scale(ica_dat1, center = TRUE, scale = TRUE), - n.comp = 3) + ic_obj <- fastICA::fastICA(scale(ica_dat1, center = TRUE, scale = TRUE), n.comp = 3) ica_dat2_exp <- as.matrix(ica_dat2_scaled) %*% ic_obj$K %*% ic_obj$W colnames(ica_dat2_exp) <- paste("ICA", 1:ncol(ic_obj$W), sep = "") expect_equal(as.data.frame(ica_dat2_exp, stringsAsFactors = TRUE), ica_dat2_ica, tolerance = .00001) diff --git a/pkg/caret/tests/testthat/test_recipe_upsample.R b/pkg/caret/tests/testthat/test_recipe_upsample.R index 7b5218e0..452f1c50 100644 --- a/pkg/caret/tests/testthat/test_recipe_upsample.R +++ b/pkg/caret/tests/testthat/test_recipe_upsample.R @@ -1,23 +1,14 @@ - -library(testthat) -library(caret) -library(themis) - context('upsampling with recipes') -# ------------------------------------------------------------------------------ - -set.seed(2542) -dat <- twoClassSim(200, intercept = 6) - -# ------------------------------------------------------------------------------ - -rec <- - recipe(Class ~ TwoFactor1 + TwoFactor2 + Linear01, data = dat) %>% - themis::step_upsample(Class, seed = 534) +test_that("model test", { + skip_if_not_installed("themis") + withr::local_seed(2542) + dat <- twoClassSim(200, intercept = 6) + rec <- + recipe(Class ~ TwoFactor1 + TwoFactor2 + Linear01, data = dat) %>% + themis::step_upsample(Class, seed = 534) -test_that("model test", { mod <- train(rec, dat, method = "knn", trControl = trainControl(method = "cv")) expect_equivalent( rep(max(table(dat$Class)), 2),