Skip to content

Commit

Permalink
Unit test for issue #612
Browse files Browse the repository at this point in the history
  • Loading branch information
topepo committed Apr 7, 2017
1 parent 1ca4375 commit ea00ca6
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions pkg/caret/tests/testthat/test_sampling_options.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,32 @@ test_that('check missing method', {
skip_on_cran()
expect_error(getSamplingInfo("plum"))
})

###################################################################
##

set.seed(2)
training <- twoClassSim(200, intercept = -10)

check_samp <- function(x, samp) {
with_form <- train(Class ~ Linear01, data = x,
method = "lda",
trControl = trainControl(method = "cv",
sampling = samp))
no_form <- train(x = x[, "Linear01", drop = FALSE],
y = x$Class,
method = "lda",
trControl = trainControl(method = "cv",
sampling = samp))
TRUE
}

test_that('downsampling with one var for issue #612', {
skip_on_cran()
expect_true(check_samp(training, "down"))
expect_true(check_samp(training, "up"))
expect_true(check_samp(training, "rose"))
expect_true(check_samp(training, "smote"))
})


0 comments on commit ea00ca6

Please sign in to comment.