From f4473972015014fe2f08973b77852eddf4329a73 Mon Sep 17 00:00:00 2001 From: bcjaeger Date: Thu, 2 May 2024 09:51:39 -0400 Subject: [PATCH] add tests for n_predictor_min = 1 --- tests/testthat/test-orsf_vs.R | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/testthat/test-orsf_vs.R b/tests/testthat/test-orsf_vs.R index f5076b65..c1180140 100644 --- a/tests/testthat/test-orsf_vs.R +++ b/tests/testthat/test-orsf_vs.R @@ -91,6 +91,21 @@ test_that( } ) +test_that( + desc = "variable selection can go down to 1 predictor", + code = { + + fit_cars <- orsf(mpg ~ ., data = mtcars, n_tree = n_tree_test) + + vs <- orsf_vs(fit_cars, n_predictor_min = 1) + # assert that we eliminated 1 predictor at each step and got down to + # 1 remaining predictor + expect_equal(nrow(vs), ncol(mtcars) - 1) + expect_length(vs$variables_included[[1]], 1) + expect_length(vs$predictors_included[[1]], 1) + + } +)