From 2be747ace35ef31f6d619cac33897e282f0efedc Mon Sep 17 00:00:00 2001 From: Nima Hejazi Date: Wed, 21 Apr 2021 16:04:28 -0700 Subject: [PATCH 1/4] further disable lightgbm tests on windows --- tests/testthat/test-lightgbm.R | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/testthat/test-lightgbm.R b/tests/testthat/test-lightgbm.R index b8654f48..593ff00a 100644 --- a/tests/testthat/test-lightgbm.R +++ b/tests/testthat/test-lightgbm.R @@ -11,28 +11,29 @@ task <- sl3_Task$new(cpp_imputed, covariates = covars, outcome = outcome) test_learner <- function(learner, task, ...) { # test learner definition: this requires that a learner can be instantiated # with only default arguments. Not sure if this is a reasonable requirement - learner_obj <- learner$new(...) print(sprintf("Testing Learner: %s", learner_obj$name)) + # test learner training - fit_obj <- learner_obj$train(task) test_that("Learner can be trained on data", { skip_on_os("windows") + learner_obj <- learner$new(...) + fit_obj <- learner_obj$train(task) expect_true(fit_obj$is_trained) }) # test learner prediction - train_preds <- fit_obj$predict() test_that("Learner can generate training set predictions", { skip_on_os("windows") + train_preds <- fit_obj$predict() expect_equal( sl3:::safe_dim(train_preds)[1], length(task$Y) ) }) # test learner chaining - chained_task <- fit_obj$chain() test_that("Chaining returns a task", { skip_on_os("windows") + chained_task <- fit_obj$chain() expect_true(is(chained_task, "sl3_Task")) }) test_that("Chaining returns the correct number of rows", { From 6687dda685a04a101badf562d78895baa5f78f60 Mon Sep 17 00:00:00 2001 From: Nima Hejazi Date: Wed, 21 Apr 2021 16:52:41 -0700 Subject: [PATCH 2/4] disable lGBM importance test on windows --- tests/testthat/test-screeners.R | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/testthat/test-screeners.R b/tests/testthat/test-screeners.R index 96697852..19001cb4 100644 --- a/tests/testthat/test-screeners.R +++ b/tests/testthat/test-screeners.R @@ -109,7 +109,16 @@ test_importance_screener <- function(learner) { } test_that("Lrnr_screener_importance tests", { + # get all learners supporting variable importance importance_learners <- sl3::sl3_list_learners("importance") + + # remove LightGBM on Windows + if (Sys.info()["sysname"] == "Windows") { + importance_learners <- + importance_learners[!(importance_learners == "Lrnr_lightgbm")] + } + + # test all learners supporting variable importance lapply(importance_learners, test_importance_screener) }) From 04449020311f9d33dee12a12a92df11bf1fe61a9 Mon Sep 17 00:00:00 2001 From: Nima Hejazi Date: Wed, 21 Apr 2021 17:36:31 -0700 Subject: [PATCH 3/4] fix tweak in test wrapper --- tests/testthat/test-lightgbm.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-lightgbm.R b/tests/testthat/test-lightgbm.R index 593ff00a..5c7a91e9 100644 --- a/tests/testthat/test-lightgbm.R +++ b/tests/testthat/test-lightgbm.R @@ -11,12 +11,12 @@ task <- sl3_Task$new(cpp_imputed, covariates = covars, outcome = outcome) test_learner <- function(learner, task, ...) { # test learner definition: this requires that a learner can be instantiated # with only default arguments. Not sure if this is a reasonable requirement + learner_obj <- learner$new(...) print(sprintf("Testing Learner: %s", learner_obj$name)) # test learner training test_that("Learner can be trained on data", { skip_on_os("windows") - learner_obj <- learner$new(...) fit_obj <- learner_obj$train(task) expect_true(fit_obj$is_trained) }) From ad43f250917b17828893e600aa7dafd4771090a3 Mon Sep 17 00:00:00 2001 From: Nima Hejazi Date: Thu, 22 Apr 2021 11:45:49 -0700 Subject: [PATCH 4/4] fix lightgbm testing order --- man/Lrnr_haldensify.Rd | 9 +++++++++ tests/testthat/test-lightgbm.R | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/man/Lrnr_haldensify.Rd b/man/Lrnr_haldensify.Rd index 2358e816..5b636244 100644 --- a/man/Lrnr_haldensify.Rd +++ b/man/Lrnr_haldensify.Rd @@ -33,6 +33,15 @@ to be divided into. sequence of values of the regulariztion parameter of the Lasso regression, to be passed to to \code{\link[hal9001]{fit_hal}}. } +\item{\code{trim_dens = 1/sqrt(n)}}{A \code{numeric} giving the minimum +allowed value of the resultant density predictions. Any predicted +density values below this tolerance threshold are set to the indicated +minimum. The default is to use the inverse of the square root of the +sample size of the prediction set, i.e., 1/sqrt(n); another notable +choice is 1/sqrt(n)/log(n). If there are observations in the prediction +set with values of \code{new_A} outside of the support of the training +set, their predictions are similarly truncated. +} \item{\code{...}}{ Other parameters passed directly to \code{\link[haldensify]{haldensify}}. See its documentation for details. } diff --git a/tests/testthat/test-lightgbm.R b/tests/testthat/test-lightgbm.R index 5c7a91e9..9493c1e6 100644 --- a/tests/testthat/test-lightgbm.R +++ b/tests/testthat/test-lightgbm.R @@ -24,6 +24,7 @@ test_learner <- function(learner, task, ...) { # test learner prediction test_that("Learner can generate training set predictions", { skip_on_os("windows") + fit_obj <- learner_obj$train(task) train_preds <- fit_obj$predict() expect_equal( sl3:::safe_dim(train_preds)[1], length(task$Y) @@ -33,11 +34,15 @@ test_learner <- function(learner, task, ...) { # test learner chaining test_that("Chaining returns a task", { skip_on_os("windows") + fit_obj <- learner_obj$train(task) chained_task <- fit_obj$chain() expect_true(is(chained_task, "sl3_Task")) }) + test_that("Chaining returns the correct number of rows", { skip_on_os("windows") + fit_obj <- learner_obj$train(task) + chained_task <- fit_obj$chain() expect_equal(nrow(chained_task$X), nrow(task$X)) }) }