Skip to content

Commit

Permalink
test step size of 2
Browse files Browse the repository at this point in the history
  • Loading branch information
bcjaeger committed Nov 22, 2024
1 parent 3e40782 commit 324d614
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
8 changes: 8 additions & 0 deletions R/orsf_vs.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ orsf_vs <- function(object,
arg_name = 'n_predictor_min',
bound = 1)


check_arg_type(arg_value = n_predictor_drop,
arg_name = 'n_predictor_drop',
expected_type = 'numeric')

check_arg_is_integer(arg_value = n_predictor_drop,
arg_name = 'n_predictor_drop')

check_arg_lt(arg_value = n_predictor_min,
arg_name = 'n_predictor_min',
bound = length(object$get_names_x()),
Expand Down
15 changes: 15 additions & 0 deletions tests/testthat/test-orsf_vs.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,19 @@ test_that(
}
)

test_that(
desc = "variable selection with step size > 1",
code = {

fit_cars <- orsf(mpg ~ ., data = mtcars, n_tree = n_tree_test)

vs_size_2 <- orsf_vs(fit_cars, n_predictor_min = 1, n_predictor_drop = 2)

# assert that we eliminated 2 predictors at each step and got down to
# 1 remaining predictor
expect_equal(vs_size_2$n_predictors, c(1,2,4,6,8,10))

}
)


0 comments on commit 324d614

Please sign in to comment.