From 08b6274f3423aafd59a532b42e32f06a6f2808df Mon Sep 17 00:00:00 2001 From: Zhi-Qiang Lei Date: Tue, 1 Jun 2021 09:36:24 +0800 Subject: [PATCH 01/39] Use sample_prop instead of sample_size Only values between 0 to 1 are allowed. --- R/lightgbm.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/lightgbm.R b/R/lightgbm.R index 227e2d1..61ea6f5 100644 --- a/R/lightgbm.R +++ b/R/lightgbm.R @@ -168,7 +168,7 @@ add_boost_tree_lightgbm <- function() { eng = "lightgbm", parsnip = "sample_size", original = "bagging_fraction", - func = list(pkg = "dials", fun = "sample_size"), + func = list(pkg = "dials", fun = "sample_prop"), has_submodel = FALSE ) } From f6109a4fa1ff34105e97babed87866001fd9d99c Mon Sep 17 00:00:00 2001 From: Daniel Falbel Date: Wed, 2 Jun 2021 14:59:31 -0300 Subject: [PATCH 02/39] install pandoc --- .github/workflows/R-CMD-check.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index a492eac..6d3bef8 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -12,6 +12,7 @@ jobs: steps: - uses: actions/checkout@v2 - uses: r-lib/actions/setup-r@master + - uses: r-lib/actions/setup-pandoc@v1 - name: Install remotes run: install.packages(c("remotes", "rcmdcheck")) shell: Rscript {0} From feeaf7052db3794d5a74b4bb73a849b330208472 Mon Sep 17 00:00:00 2001 From: Daniel Falbel Date: Wed, 2 Jun 2021 15:17:36 -0300 Subject: [PATCH 03/39] reduce dataset size to speedup vignette --- vignettes/working-with-lightgbm-catboost.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vignettes/working-with-lightgbm-catboost.Rmd b/vignettes/working-with-lightgbm-catboost.Rmd index 05c11c4..7ffa998 100644 --- a/vignettes/working-with-lightgbm-catboost.Rmd +++ b/vignettes/working-with-lightgbm-catboost.Rmd @@ -20,7 +20,7 @@ knitr::opts_chunk$set( library(tidymodels) library(treesnip) data("diamonds", package = "ggplot2") - +diamonds <- diamonds %>% sample_n(1000) # vfold resamples diamonds_splits <- vfold_cv(diamonds, v = 5) ``` From 2fa6032d02d7fb65a1477de5dfc07bb9ffce6214 Mon Sep 17 00:00:00 2001 From: Daniel Falbel Date: Wed, 2 Jun 2021 15:19:33 -0300 Subject: [PATCH 04/39] use an updated version of catboost --- .github/workflows/R-CMD-check.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 6d3bef8..dd0ab53 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -18,7 +18,7 @@ jobs: shell: Rscript {0} - name: Install catboost run: | - remotes::install_url("https://github.com/catboost/catboost/releases/download/v0.23/catboost-R-Windows-0.23.tgz", INSTALL_opts = c("--no-multiarch")) + remotes::install_url("https://github.com/catboost/catboost/releases/download/v0.25.1/catboost-R-Windows-0.25.1.tgz", INSTALL_opts = c("--no-multiarch")) shell: Rscript {0} - name: Install dependencies run: | From 75628d6293cb8b2dbd6aa2a5a7710f04ce55ede8 Mon Sep 17 00:00:00 2001 From: Daniel Falbel Date: Wed, 2 Jun 2021 15:36:11 -0300 Subject: [PATCH 05/39] skip eval to proceed --- vignettes/working-with-lightgbm-catboost.Rmd | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vignettes/working-with-lightgbm-catboost.Rmd b/vignettes/working-with-lightgbm-catboost.Rmd index 7ffa998..6311a01 100644 --- a/vignettes/working-with-lightgbm-catboost.Rmd +++ b/vignettes/working-with-lightgbm-catboost.Rmd @@ -12,7 +12,8 @@ knitr::opts_chunk$set( collapse = TRUE, comment = "#>", warning = FALSE, - message = FALSE + message = FALSE, + eval = FALSE ) ``` From 8806704c23b962386db8124bbd3d440a9101f394 Mon Sep 17 00:00:00 2001 From: Daniel Falbel Date: Wed, 2 Jun 2021 15:36:29 -0300 Subject: [PATCH 06/39] update gitignore --- vignettes/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/vignettes/.gitignore b/vignettes/.gitignore index 097b241..b0d93a3 100644 --- a/vignettes/.gitignore +++ b/vignettes/.gitignore @@ -1,2 +1,3 @@ *.html *.R +working-with-lightgbm-catboost_cache From 2e4bf83f70025bc1681c21ad2b15380f5d892591 Mon Sep 17 00:00:00 2001 From: Daniel Falbel Date: Fri, 9 Jul 2021 18:02:41 -0300 Subject: [PATCH 07/39] Add more suggests --- DESCRIPTION | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index cc6465d..a17a373 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -23,7 +23,9 @@ Suggests: lightgbm, knitr, rmarkdown, - readr + readr, + glue, + scales RoxygenNote: 7.1.1 Imports: rlang, From f7fb488880f3f61d24e9a49c6f777f8e07442f0b Mon Sep 17 00:00:00 2001 From: Daniel Falbel Date: Fri, 9 Jul 2021 18:03:24 -0300 Subject: [PATCH 08/39] don't try to add the model if it's already registered. --- R/train.R | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/R/train.R b/R/train.R index 7cc6f51..e66fe08 100644 --- a/R/train.R +++ b/R/train.R @@ -1,7 +1,18 @@ + .onLoad <- function(libname, pkgname){ - add_decision_tree_tree() - add_boost_tree_catboost() - add_boost_tree_lightgbm() + + if (!"lightgbm" %in% parsnip::get_model_env()$boost_tree$engine) { + add_boost_tree_lightgbm() + } + + if (!"catboost" %in% parsnip::get_model_env()$boost_tree$engine) { + add_boost_tree_catboost() + } + + if (!"tree" %in% parsnip::get_model_env()$decision_tree$engine) { + add_decision_tree_tree() + } + } From 2e9996a1641a988d2bb814b95c91359cca4ed463 Mon Sep 17 00:00:00 2001 From: Daniel Falbel Date: Fri, 9 Jul 2021 18:14:31 -0300 Subject: [PATCH 09/39] ignore vignette cache directories --- vignettes/.gitignore | 3 +++ .../parallel-processing_cache/html/__packages | 19 ------------------ ...ode_fed05125bc1448aed90ee1abe24570d5.RData | Bin 3466 -> 0 bytes .../code_fed05125bc1448aed90ee1abe24570d5.rdb | 0 .../code_fed05125bc1448aed90ee1abe24570d5.rdx | Bin 124 -> 0 bytes ...ing_0880993d5c4023853d50944ad1d59fbe.RData | Bin 2979 -> 0 bytes ...rking_0880993d5c4023853d50944ad1d59fbe.rdb | 0 ...rking_0880993d5c4023853d50944ad1d59fbe.rdx | Bin 124 -> 0 bytes .../html/__packages | 19 ------------------ ...ode_0f350d3724cc7b8a16bedcde1d89a6be.RData | Bin 746 -> 0 bytes .../code_0f350d3724cc7b8a16bedcde1d89a6be.rdb | 0 .../code_0f350d3724cc7b8a16bedcde1d89a6be.rdx | Bin 124 -> 0 bytes 12 files changed, 3 insertions(+), 38 deletions(-) delete mode 100644 vignettes/parallel-processing_cache/html/__packages delete mode 100644 vignettes/parallel-processing_cache/html/code_fed05125bc1448aed90ee1abe24570d5.RData delete mode 100644 vignettes/parallel-processing_cache/html/code_fed05125bc1448aed90ee1abe24570d5.rdb delete mode 100644 vignettes/parallel-processing_cache/html/code_fed05125bc1448aed90ee1abe24570d5.rdx delete mode 100644 vignettes/parallel-processing_cache/html/forking_0880993d5c4023853d50944ad1d59fbe.RData delete mode 100644 vignettes/parallel-processing_cache/html/forking_0880993d5c4023853d50944ad1d59fbe.rdb delete mode 100644 vignettes/parallel-processing_cache/html/forking_0880993d5c4023853d50944ad1d59fbe.rdx delete mode 100644 vignettes/threading-forking-benchmark_cache/html/__packages delete mode 100644 vignettes/threading-forking-benchmark_cache/html/code_0f350d3724cc7b8a16bedcde1d89a6be.RData delete mode 100644 vignettes/threading-forking-benchmark_cache/html/code_0f350d3724cc7b8a16bedcde1d89a6be.rdb delete mode 100644 vignettes/threading-forking-benchmark_cache/html/code_0f350d3724cc7b8a16bedcde1d89a6be.rdx diff --git a/vignettes/.gitignore b/vignettes/.gitignore index b0d93a3..22cde80 100644 --- a/vignettes/.gitignore +++ b/vignettes/.gitignore @@ -1,3 +1,6 @@ *.html *.R working-with-lightgbm-catboost_cache +threading-forking-benchmark_cache +parallel-processing_cache +catboost_info diff --git a/vignettes/parallel-processing_cache/html/__packages b/vignettes/parallel-processing_cache/html/__packages deleted file mode 100644 index 6568700..0000000 --- a/vignettes/parallel-processing_cache/html/__packages +++ /dev/null @@ -1,19 +0,0 @@ -base -tidymodels -broom -scales -dials -dplyr -ggplot2 -infer -modeldata -parsnip -purrr -recipes -rsample -tibble -tidyr -tune -workflows -yardstick -treesnip diff --git a/vignettes/parallel-processing_cache/html/code_fed05125bc1448aed90ee1abe24570d5.RData b/vignettes/parallel-processing_cache/html/code_fed05125bc1448aed90ee1abe24570d5.RData deleted file mode 100644 index 7b24175335872ddd8b4f609eccebc4ad05a68640..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3466 zcmV;54R!J#iwFP!000001Ep7aJXCudA6qvQQmJflY?)yUlVvOs*_R?q)*55xm>IJ+ zGZ`bKtf_>MB+C_Y6=jJiN@+(@bVb?I?(%YPS$fY5)xCY*f8NiXf6n_;@?$nZjV=qR>GEQbnm`FvntjxzYN|#cl7P)hmGAa)`Y>pBGx-!99E_CfN7RU z1=C=qY?SttI7xi=fq`~$yxU#dGDmC6*nuy~izjLyg zaEtrm&F0;+U3yX2Obv$}s(JNtVozEpZD!K+wA&AjADw&`E^;}bG3?6TigwMcY@3ZD zrG}b{eS|O(KG}@k2aHu}ELa6CwLBl7;F0M9X zS_Mb?zFFb9^X11qmcRVo=N>$-Hj=WHkw z4Epu`uKQu$S((@nBYlLF8+I5!E|Vhvs-#1!C6#6UDq6|?Ond1GvMZrR{&uxVvAomJ zm}=e%g-2c$Usk&HZL{uqW)PYdE&iI4=NVj*T@_X*wI*@f@Ap#6+w|K_kVo?e81MXA zyKm18ou89fTaadRtFk1_w^cuKl05M{+;`xJLroC^MfFNfTCpc{W) zLq3|cV>qzUt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1t3>gKSG@ilGp;uF&XMV>6hR@;5ldl8A6)?fsI&_AyEKh2~$D%C2$1^ zmgd3>6%0iHbtsL=L;Ni&o=9Ap8sgjdeo`*adK5vI#amG|F8|E&>(9ZiSV<6 sOQD0f{R|3MfGb^HC>697EigbY!}vFbAO%-6bY(C87qg01WEc|6BxbZ66cUi)h?vp9q8y;8?hzQ5 zl$T{VL6Ko%%8&L{6F%Cnl3^B)FqT++!q}PjiH^6-3Ldb@R~ aJbx}GvQ$ib`LYHcR)z&W9H({yEd>B&swh+d diff --git a/vignettes/parallel-processing_cache/html/forking_0880993d5c4023853d50944ad1d59fbe.RData b/vignettes/parallel-processing_cache/html/forking_0880993d5c4023853d50944ad1d59fbe.RData deleted file mode 100644 index 4873aadf335fc5a514fcc6666f27e08980643f58..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2979 zcmV;U3taRciwFP!0000016@{mJQMsM-ZUZ>*z$C3ikvV$3T7qq45Gg<6?uDa0LSd%7izy%6ec^Kb=Z&&}Y_iU7 zu?W=_5FWJtOh>gO*5QeHxi!ipdg6!dc53}|e_h6^lf=fF=ta-nwS0|Z)}U0qBaYh- zTTibKXhpy?m8?$47c@%nzwF?et)*$H_Fi1L!u=2myzA8*bnh&?S2-)&>>#jAPg!~t z69i-iB7#RD^VLdQ_e*A{_JHexP80~ag#V~X6YkIIdVZ%itM!S`OzM1S-rGi0u_fBZp>R3>x7u!!POsseJD%87!#dphtm z$Tcey?ys*66>@;jpch1vB;S_yskEg~P;Vn;9IyA5r3Tt#>Lef48kR`fOwY>~?2>x! z!v3+_Ve}Yk=(SEjS|sQlp}^U%G`l9KK}bCQ*qiQ@iZ1P5L$xb~6CocwItCwYOyAxR z*vm>Y>#Qyfa_`U%=LRmm0lQCJwyG?G;!ryf{eQ1eK>9YDi~P4a!~` znw5B-eLS#a&bSw=Ft%0&$C;M@r;S6$<0MPR&FarN$RUodfswTlJwa1 zA_+!7mCDhWN`WVJDx}$2eQSwxi|li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jiH^6-3Ldb@R~ aJbx}GvQ$ib`LYHcR)z&W9H({yEd>B&swh+d diff --git a/vignettes/threading-forking-benchmark_cache/html/__packages b/vignettes/threading-forking-benchmark_cache/html/__packages deleted file mode 100644 index 6568700..0000000 --- a/vignettes/threading-forking-benchmark_cache/html/__packages +++ /dev/null @@ -1,19 +0,0 @@ -base -tidymodels -broom -scales -dials -dplyr -ggplot2 -infer -modeldata -parsnip -purrr -recipes -rsample -tibble -tidyr -tune -workflows -yardstick -treesnip diff --git a/vignettes/threading-forking-benchmark_cache/html/code_0f350d3724cc7b8a16bedcde1d89a6be.RData b/vignettes/threading-forking-benchmark_cache/html/code_0f350d3724cc7b8a16bedcde1d89a6be.RData deleted file mode 100644 index 55a145fa4c984cf66674bb8f4d54d00a1d8939f3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 746 zcmVbpYwf3*BAGr@IDNJU_00ewu0?l{0(;RZm;&o zL9nxhmv^XmkLS0f3 z!3;xVkwwJYl{oLhT287;o76M_6g7mDrg=uoQB2&`Dm30t27^|jSy>m5YWc%h6c c)~hv0S{T|6BxbZ66cUi)h?vp9q8y;8?hzQ5 zl$T{VL6Ko%%8&L{6F%Cnl3^B)FqT++!q}PjiH^6-3Ldb@R~ aJbx}GvQ$ib`LYHcR)z&W9H({yEd>B&swh+d From ea1a5bf9a5b71604a8dc4bc7ae2fde2e0871d9e5 Mon Sep 17 00:00:00 2001 From: Daniel Falbel Date: Fri, 9 Jul 2021 18:43:22 -0300 Subject: [PATCH 10/39] Fix the tests in catboost --- R/catboost.R | 2 +- tests/testthat/helper-model.R | 3 +++ tests/testthat/test-catboost.R | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/R/catboost.R b/R/catboost.R index f1ad633..7d6f1db 100644 --- a/R/catboost.R +++ b/R/catboost.R @@ -191,7 +191,7 @@ add_boost_tree_catboost <- function() { eng = "catboost", parsnip = "sample_size", original = "subsample", - func = list(pkg = "dials", fun = "sample_size"), + func = list(pkg = "dials", fun = "sample_prop"), has_submodel = FALSE ) } diff --git a/tests/testthat/helper-model.R b/tests/testthat/helper-model.R index ccd7fb9..fff5483 100644 --- a/tests/testthat/helper-model.R +++ b/tests/testthat/helper-model.R @@ -92,6 +92,9 @@ expect_categorical_vars_works <- function(model) { } expect_can_tune_boost_tree <- function(model) { + + mtcars <- rbind(mtcars, mtcars) + mtcars$cyl <- factor(mtcars$cyl) mtcars$vs <- factor(mtcars$vs) diff --git a/tests/testthat/test-catboost.R b/tests/testthat/test-catboost.R index 0e85a95..d361e0a 100644 --- a/tests/testthat/test-catboost.R +++ b/tests/testthat/test-catboost.R @@ -16,8 +16,8 @@ test_that('catboost alternate objective', { info <- catboost::catboost.get_model_params(cat_fit$fit) expect_equal(info$loss_function$type, "Huber") - expect_equal(info$loss_function$params[1], "delta") - expect_equal(info$loss_function$params[2], "1") + expect_true(grepl("delta", info$loss_function$params[1])) + expect_equal(info$loss_function$params[[2]], "1") }) test_that("catboost with tune", { From abaac2ef2e95521ca8ef8c838ff3e5d1627f8f63 Mon Sep 17 00:00:00 2001 From: Daniel Falbel Date: Fri, 9 Jul 2021 18:52:02 -0300 Subject: [PATCH 11/39] use larger sample to fix error from catboost. --- tests/testthat/helper-model.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/helper-model.R b/tests/testthat/helper-model.R index fff5483..42e833a 100644 --- a/tests/testthat/helper-model.R +++ b/tests/testthat/helper-model.R @@ -93,7 +93,7 @@ expect_categorical_vars_works <- function(model) { expect_can_tune_boost_tree <- function(model) { - mtcars <- rbind(mtcars, mtcars) + mtcars <- dplyr::sample_n(mtcars, size = 500, replace = TRUE) mtcars$cyl <- factor(mtcars$cyl) mtcars$vs <- factor(mtcars$vs) From 9720e0b0d029f41f8daf8e1dc75c1df1cef7ba19 Mon Sep 17 00:00:00 2001 From: Daniel Falbel Date: Fri, 9 Jul 2021 18:52:17 -0300 Subject: [PATCH 12/39] port fix from #46 for tree --- R/tree.R | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/R/tree.R b/R/tree.R index 79d2eec..32d1b08 100644 --- a/R/tree.R +++ b/R/tree.R @@ -12,6 +12,18 @@ add_decision_tree_tree <- function() { parsnip::set_dependency("decision_tree", eng = "tree", pkg = "tree") + parsnip::set_encoding( + model = "decision_tree", + eng = "tree", + mode = "regression", + options = list( + predictor_indicators = "none", + compute_intercept = FALSE, + remove_intercept = FALSE, + allow_sparse_x = FALSE + ) + ) + parsnip::set_fit( model = "decision_tree", eng = "tree", From f1fb3d402e1fb3f7d9fe2d60e3e43339f427ea48 Mon Sep 17 00:00:00 2001 From: Daniel Falbel Date: Fri, 9 Jul 2021 19:02:45 -0300 Subject: [PATCH 13/39] reveal testthat output to debug failure --- .github/workflows/R-CMD-check.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index dd0ab53..8ab7193 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -27,3 +27,7 @@ jobs: - name: Check run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--no-multiarch"), error_on = "error") shell: Rscript {0} + - name: Show testthat output + if: always() + run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true + shell: bash From 2161b12253dddd672e035536c06a4c1b77ebc33b Mon Sep 17 00:00:00 2001 From: Daniel Falbel Date: Fri, 9 Jul 2021 19:24:48 -0300 Subject: [PATCH 14/39] update catboost and add quick checks for catboost and lightgbm --- .github/workflows/R-CMD-check.yaml | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 8ab7193..74db4fb 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -18,12 +18,33 @@ jobs: shell: Rscript {0} - name: Install catboost run: | - remotes::install_url("https://github.com/catboost/catboost/releases/download/v0.25.1/catboost-R-Windows-0.25.1.tgz", INSTALL_opts = c("--no-multiarch")) + remotes::install_url("https://github.com/catboost/catboost/releases/download/v0.26/catboost-R-Windows-0.26.tgz", INSTALL_opts = c("--no-multiarch")) shell: Rscript {0} - name: Install dependencies run: | remotes::install_deps(dependencies = TRUE, INSTALL_opts = c("--no-multiarch")) shell: Rscript {0} + - name: catboost + run: | + library(catboost) + features <- data.frame(feature1 = c(1, 2, 3), feature2 = factor(c('A', 'B', 'C'))) + labels <- c(0, 0, 1) + train_pool <- catboost.load_pool(data = features, label = labels) + shell: Rscript {0} + - name: lightgbm + run: | + library(lightgbm) + data(agaricus.train, package='lightgbm') + train <- agaricus.train + dtrain <- lgb.Dataset(train$data, label = train$label) + model <- lgb.cv( + params = list( + objective = "regression" + , metric = "l2" + ) + , data = dtrain + ) + shell: Rscript {0} - name: Check run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--no-multiarch"), error_on = "error") shell: Rscript {0} From 4c302754d2ed9add3c882f08eea61c5101c6097c Mon Sep 17 00:00:00 2001 From: Daniel Falbel Date: Fri, 9 Jul 2021 19:31:16 -0300 Subject: [PATCH 15/39] add check dir --- .github/workflows/R-CMD-check.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 74db4fb..f8efc0a 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -46,7 +46,7 @@ jobs: ) shell: Rscript {0} - name: Check - run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--no-multiarch"), error_on = "error") + run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--no-multiarch"), error_on = "error", check_dir = "check") shell: Rscript {0} - name: Show testthat output if: always() From 20778fa1f38096228d8c57e982cbd1635f5e483e Mon Sep 17 00:00:00 2001 From: Daniel Falbel Date: Fri, 9 Jul 2021 19:45:04 -0300 Subject: [PATCH 16/39] debug: commenting out most catboost tests to test --- tests/testthat/test-catboost.R | 162 ++++++++++++++++----------------- 1 file changed, 81 insertions(+), 81 deletions(-) diff --git a/tests/testthat/test-catboost.R b/tests/testthat/test-catboost.R index d361e0a..591c9f7 100644 --- a/tests/testthat/test-catboost.R +++ b/tests/testthat/test-catboost.R @@ -5,84 +5,84 @@ test_that("catboost", { }) -test_that('catboost alternate objective', { - skip_if_not_installed("catboost") - - spec <- boost_tree() %>% - set_engine("catboost", loss_function = "Huber:delta=1") %>% - set_mode("regression") - - cat_fit <- spec %>% fit(mpg ~ ., data = mtcars) - info <- catboost::catboost.get_model_params(cat_fit$fit) - - expect_equal(info$loss_function$type, "Huber") - expect_true(grepl("delta", info$loss_function$params[1])) - expect_equal(info$loss_function$params[[2]], "1") -}) - -test_that("catboost with tune", { - - model <- parsnip::boost_tree( - mtry = 5, - learn_rate = tune(), - loss_reduction = tune(), - sample_size = tune(), - trees = tune(), - min_n = tune(), - tree_depth = tune() - ) - model <- parsnip::set_engine(model, "catboost") - - expect_can_tune_boost_tree(model) - -}) - - -test_that("catboost mtry", { - - hyperparameters <- data.frame(mtry = c(1, 2, 6)) - for(i in 1:nrow(hyperparameters)) { - model <- parsnip::boost_tree(mtry = hyperparameters$mtry[i]) - expect_all_modes_works(model, 'catboost') - } - -}) - -test_that("catboost trees", { - - hyperparameters <- data.frame(trees = c(1, 20, 300)) - for(i in 1:nrow(hyperparameters)) { - model <- parsnip::boost_tree(trees = hyperparameters$trees[i]) - expect_all_modes_works(model, 'catboost') - } - -}) - - -test_that("catboost min_n hiperparameter", { - - hyperparameters <- data.frame(min_n = c(1, 10)) - for(i in 1:nrow(hyperparameters)) { - model <- parsnip::boost_tree(min_n = hyperparameters$min_n[i]) - expect_all_modes_works(model, 'catboost') - } - -}) - -test_that("catboost tree_depth", { - - hyperparameters <- data.frame(tree_depth = c(1, 16)) - for(i in 1:nrow(hyperparameters)) { - model <- parsnip::boost_tree(tree_depth = hyperparameters$tree_depth[i]) - expect_all_modes_works(model, 'catboost') - } - -}) - -test_that("catboost multi_predict", { - model <- parsnip::boost_tree(mtry = 5, trees = 5, mode = "regression") - model <- parsnip::set_engine(model, "catboost") - - expect_multi_predict_works(model) -}) - +# test_that('catboost alternate objective', { +# skip_if_not_installed("catboost") +# +# spec <- boost_tree() %>% +# set_engine("catboost", loss_function = "Huber:delta=1") %>% +# set_mode("regression") +# +# cat_fit <- spec %>% fit(mpg ~ ., data = mtcars) +# info <- catboost::catboost.get_model_params(cat_fit$fit) +# +# expect_equal(info$loss_function$type, "Huber") +# expect_true(grepl("delta", info$loss_function$params[1])) +# expect_equal(info$loss_function$params[[2]], "1") +# }) +# +# test_that("catboost with tune", { +# +# model <- parsnip::boost_tree( +# mtry = 5, +# learn_rate = tune(), +# loss_reduction = tune(), +# sample_size = tune(), +# trees = tune(), +# min_n = tune(), +# tree_depth = tune() +# ) +# model <- parsnip::set_engine(model, "catboost") +# +# expect_can_tune_boost_tree(model) +# +# }) +# +# +# test_that("catboost mtry", { +# +# hyperparameters <- data.frame(mtry = c(1, 2, 6)) +# for(i in 1:nrow(hyperparameters)) { +# model <- parsnip::boost_tree(mtry = hyperparameters$mtry[i]) +# expect_all_modes_works(model, 'catboost') +# } +# +# }) +# +# test_that("catboost trees", { +# +# hyperparameters <- data.frame(trees = c(1, 20, 300)) +# for(i in 1:nrow(hyperparameters)) { +# model <- parsnip::boost_tree(trees = hyperparameters$trees[i]) +# expect_all_modes_works(model, 'catboost') +# } +# +# }) +# +# +# test_that("catboost min_n hiperparameter", { +# +# hyperparameters <- data.frame(min_n = c(1, 10)) +# for(i in 1:nrow(hyperparameters)) { +# model <- parsnip::boost_tree(min_n = hyperparameters$min_n[i]) +# expect_all_modes_works(model, 'catboost') +# } +# +# }) +# +# test_that("catboost tree_depth", { +# +# hyperparameters <- data.frame(tree_depth = c(1, 16)) +# for(i in 1:nrow(hyperparameters)) { +# model <- parsnip::boost_tree(tree_depth = hyperparameters$tree_depth[i]) +# expect_all_modes_works(model, 'catboost') +# } +# +# }) +# +# test_that("catboost multi_predict", { +# model <- parsnip::boost_tree(mtry = 5, trees = 5, mode = "regression") +# model <- parsnip::set_engine(model, "catboost") +# +# expect_multi_predict_works(model) +# }) +# From ca9192f3d64e2d369c22fef3cd3a51473698cd75 Mon Sep 17 00:00:00 2001 From: Daniel Falbel Date: Fri, 9 Jul 2021 20:02:36 -0300 Subject: [PATCH 17/39] comment out all catboost tests to debug --- tests/testthat/test-catboost.R | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/testthat/test-catboost.R b/tests/testthat/test-catboost.R index 591c9f7..a5ceea5 100644 --- a/tests/testthat/test-catboost.R +++ b/tests/testthat/test-catboost.R @@ -1,9 +1,9 @@ -test_that("catboost", { - - model <- parsnip::boost_tree(mtry = 1, trees = 50) - expect_all_modes_works(model, 'catboost') - -}) +# test_that("catboost", { +# +# model <- parsnip::boost_tree(mtry = 1, trees = 50) +# expect_all_modes_works(model, 'catboost') +# +# }) # test_that('catboost alternate objective', { # skip_if_not_installed("catboost") From 1ddcd29a1d5bae3d69bdd6c137107794cd39a42f Mon Sep 17 00:00:00 2001 From: Daniel Falbel Date: Fri, 9 Jul 2021 20:10:21 -0300 Subject: [PATCH 18/39] now comment out lightgbm tests --- tests/testthat/test-lightgbm.R | 204 ++++++++++++++++----------------- 1 file changed, 102 insertions(+), 102 deletions(-) diff --git a/tests/testthat/test-lightgbm.R b/tests/testthat/test-lightgbm.R index 1309ffa..96e867a 100644 --- a/tests/testthat/test-lightgbm.R +++ b/tests/testthat/test-lightgbm.R @@ -1,102 +1,102 @@ -test_that("lightgbm", { - - model <- parsnip::boost_tree(mtry = 1, trees = 50, tree_depth = 15, min_n = 1) - - expect_all_modes_works(model, 'lightgbm') -}) - - -test_that('lightgbm alternate objective', { - skip_if_not_installed("lightgbm") - - spec <- boost_tree(mtry = 1, trees = 50, tree_depth = 15, min_n = 1) %>% - set_engine("lightgbm", objective = "huber") %>% - set_mode("regression") - - lgb_fit <- spec %>% fit(mpg ~ ., data = mtcars) - - info <- jsonlite::fromJSON(lightgbm::lgb.dump(lgb_fit$fit)) - - expect_equal(info$objective, "huber") -}) - -test_that("lightgbm with tune", { - - model <- parsnip::boost_tree( - mtry = 5, - learn_rate = tune(), - loss_reduction = tune(), - sample_size = tune(), - trees = tune(), - min_n = tune(), - tree_depth = tune() - ) - model <- parsnip::set_engine(model, "lightgbm") - - expect_can_tune_boost_tree(model) - -}) - - -test_that("lightgbm mtry", { - - hyperparameters <- data.frame(mtry = c(1, 2, 6)) - for(i in 1:nrow(hyperparameters)) { - model <- parsnip::boost_tree(mtry = hyperparameters$mtry[i], min_n = 1) - expect_all_modes_works(model, 'lightgbm') - } - -}) - -test_that("lightgbm trees", { - - hyperparameters <- data.frame(trees = c(1, 20, 300)) - for(i in 1:nrow(hyperparameters)) { - model <- parsnip::boost_tree(trees = hyperparameters$trees[i], min_n = 1) - expect_all_modes_works(model, 'lightgbm') - } - -}) - - -test_that("lightgbm min_n hyperparameter", { - - hyperparameters <- data.frame(min_n = c(1, 10)) - for(i in 1:nrow(hyperparameters)) { - model <- parsnip::boost_tree(min_n = hyperparameters$min_n[i]) - expect_all_modes_works(model, 'lightgbm') - } - -}) - -test_that("lightgbm tree_depth", { - hyperparameters <- data.frame(tree_depth = c(1, 16)) - for(i in 1:nrow(hyperparameters)) { - model <- parsnip::boost_tree(tree_depth = hyperparameters$tree_depth[i], min_n = 1) - expect_all_modes_works(model, 'lightgbm') - } -}) - -test_that("lightgbm loss_reduction", { - hyperparameters <- data.frame(loss_reduction = c(0, 0.2, 2)) - for(i in 1:nrow(hyperparameters)) { - model <- parsnip::boost_tree(loss_reduction = hyperparameters$loss_reduction[i], min_n = 1) - expect_all_modes_works(model, 'lightgbm') - } -}) - -test_that("lightgbm tree_depth", { - hyperparameters <- data.frame(loss_reduction = c(0, 0.2, 2)) - for(i in 1:nrow(hyperparameters)) { - model <- parsnip::boost_tree(loss_reduction = hyperparameters$loss_reduction[i], min_n = 1) - expect_all_modes_works(model, 'lightgbm') - } -}) - -test_that("lightgbm multi_predict", { - model <- parsnip::boost_tree(mtry = 5, trees = 5, mode = "regression", min_n = 1) - model <- parsnip::set_engine(model, "lightgbm") - - expect_multi_predict_works(model) -}) - +# test_that("lightgbm", { +# +# model <- parsnip::boost_tree(mtry = 1, trees = 50, tree_depth = 15, min_n = 1) +# +# expect_all_modes_works(model, 'lightgbm') +# }) +# +# +# test_that('lightgbm alternate objective', { +# skip_if_not_installed("lightgbm") +# +# spec <- boost_tree(mtry = 1, trees = 50, tree_depth = 15, min_n = 1) %>% +# set_engine("lightgbm", objective = "huber") %>% +# set_mode("regression") +# +# lgb_fit <- spec %>% fit(mpg ~ ., data = mtcars) +# +# info <- jsonlite::fromJSON(lightgbm::lgb.dump(lgb_fit$fit)) +# +# expect_equal(info$objective, "huber") +# }) +# +# test_that("lightgbm with tune", { +# +# model <- parsnip::boost_tree( +# mtry = 5, +# learn_rate = tune(), +# loss_reduction = tune(), +# sample_size = tune(), +# trees = tune(), +# min_n = tune(), +# tree_depth = tune() +# ) +# model <- parsnip::set_engine(model, "lightgbm") +# +# expect_can_tune_boost_tree(model) +# +# }) +# +# +# test_that("lightgbm mtry", { +# +# hyperparameters <- data.frame(mtry = c(1, 2, 6)) +# for(i in 1:nrow(hyperparameters)) { +# model <- parsnip::boost_tree(mtry = hyperparameters$mtry[i], min_n = 1) +# expect_all_modes_works(model, 'lightgbm') +# } +# +# }) +# +# test_that("lightgbm trees", { +# +# hyperparameters <- data.frame(trees = c(1, 20, 300)) +# for(i in 1:nrow(hyperparameters)) { +# model <- parsnip::boost_tree(trees = hyperparameters$trees[i], min_n = 1) +# expect_all_modes_works(model, 'lightgbm') +# } +# +# }) +# +# +# test_that("lightgbm min_n hyperparameter", { +# +# hyperparameters <- data.frame(min_n = c(1, 10)) +# for(i in 1:nrow(hyperparameters)) { +# model <- parsnip::boost_tree(min_n = hyperparameters$min_n[i]) +# expect_all_modes_works(model, 'lightgbm') +# } +# +# }) +# +# test_that("lightgbm tree_depth", { +# hyperparameters <- data.frame(tree_depth = c(1, 16)) +# for(i in 1:nrow(hyperparameters)) { +# model <- parsnip::boost_tree(tree_depth = hyperparameters$tree_depth[i], min_n = 1) +# expect_all_modes_works(model, 'lightgbm') +# } +# }) +# +# test_that("lightgbm loss_reduction", { +# hyperparameters <- data.frame(loss_reduction = c(0, 0.2, 2)) +# for(i in 1:nrow(hyperparameters)) { +# model <- parsnip::boost_tree(loss_reduction = hyperparameters$loss_reduction[i], min_n = 1) +# expect_all_modes_works(model, 'lightgbm') +# } +# }) +# +# test_that("lightgbm tree_depth", { +# hyperparameters <- data.frame(loss_reduction = c(0, 0.2, 2)) +# for(i in 1:nrow(hyperparameters)) { +# model <- parsnip::boost_tree(loss_reduction = hyperparameters$loss_reduction[i], min_n = 1) +# expect_all_modes_works(model, 'lightgbm') +# } +# }) +# +# test_that("lightgbm multi_predict", { +# model <- parsnip::boost_tree(mtry = 5, trees = 5, mode = "regression", min_n = 1) +# model <- parsnip::set_engine(model, "lightgbm") +# +# expect_multi_predict_works(model) +# }) +# From 48a1a3daa97fbbe0365acfd9466d02f3e47bffaa Mon Sep 17 00:00:00 2001 From: Daniel Falbel Date: Fri, 9 Jul 2021 20:20:07 -0300 Subject: [PATCH 19/39] re-enable catboost tests --- tests/testthat/test-catboost.R | 176 ++++++++++++++++----------------- 1 file changed, 88 insertions(+), 88 deletions(-) diff --git a/tests/testthat/test-catboost.R b/tests/testthat/test-catboost.R index a5ceea5..d361e0a 100644 --- a/tests/testthat/test-catboost.R +++ b/tests/testthat/test-catboost.R @@ -1,88 +1,88 @@ -# test_that("catboost", { -# -# model <- parsnip::boost_tree(mtry = 1, trees = 50) -# expect_all_modes_works(model, 'catboost') -# -# }) - -# test_that('catboost alternate objective', { -# skip_if_not_installed("catboost") -# -# spec <- boost_tree() %>% -# set_engine("catboost", loss_function = "Huber:delta=1") %>% -# set_mode("regression") -# -# cat_fit <- spec %>% fit(mpg ~ ., data = mtcars) -# info <- catboost::catboost.get_model_params(cat_fit$fit) -# -# expect_equal(info$loss_function$type, "Huber") -# expect_true(grepl("delta", info$loss_function$params[1])) -# expect_equal(info$loss_function$params[[2]], "1") -# }) -# -# test_that("catboost with tune", { -# -# model <- parsnip::boost_tree( -# mtry = 5, -# learn_rate = tune(), -# loss_reduction = tune(), -# sample_size = tune(), -# trees = tune(), -# min_n = tune(), -# tree_depth = tune() -# ) -# model <- parsnip::set_engine(model, "catboost") -# -# expect_can_tune_boost_tree(model) -# -# }) -# -# -# test_that("catboost mtry", { -# -# hyperparameters <- data.frame(mtry = c(1, 2, 6)) -# for(i in 1:nrow(hyperparameters)) { -# model <- parsnip::boost_tree(mtry = hyperparameters$mtry[i]) -# expect_all_modes_works(model, 'catboost') -# } -# -# }) -# -# test_that("catboost trees", { -# -# hyperparameters <- data.frame(trees = c(1, 20, 300)) -# for(i in 1:nrow(hyperparameters)) { -# model <- parsnip::boost_tree(trees = hyperparameters$trees[i]) -# expect_all_modes_works(model, 'catboost') -# } -# -# }) -# -# -# test_that("catboost min_n hiperparameter", { -# -# hyperparameters <- data.frame(min_n = c(1, 10)) -# for(i in 1:nrow(hyperparameters)) { -# model <- parsnip::boost_tree(min_n = hyperparameters$min_n[i]) -# expect_all_modes_works(model, 'catboost') -# } -# -# }) -# -# test_that("catboost tree_depth", { -# -# hyperparameters <- data.frame(tree_depth = c(1, 16)) -# for(i in 1:nrow(hyperparameters)) { -# model <- parsnip::boost_tree(tree_depth = hyperparameters$tree_depth[i]) -# expect_all_modes_works(model, 'catboost') -# } -# -# }) -# -# test_that("catboost multi_predict", { -# model <- parsnip::boost_tree(mtry = 5, trees = 5, mode = "regression") -# model <- parsnip::set_engine(model, "catboost") -# -# expect_multi_predict_works(model) -# }) -# +test_that("catboost", { + + model <- parsnip::boost_tree(mtry = 1, trees = 50) + expect_all_modes_works(model, 'catboost') + +}) + +test_that('catboost alternate objective', { + skip_if_not_installed("catboost") + + spec <- boost_tree() %>% + set_engine("catboost", loss_function = "Huber:delta=1") %>% + set_mode("regression") + + cat_fit <- spec %>% fit(mpg ~ ., data = mtcars) + info <- catboost::catboost.get_model_params(cat_fit$fit) + + expect_equal(info$loss_function$type, "Huber") + expect_true(grepl("delta", info$loss_function$params[1])) + expect_equal(info$loss_function$params[[2]], "1") +}) + +test_that("catboost with tune", { + + model <- parsnip::boost_tree( + mtry = 5, + learn_rate = tune(), + loss_reduction = tune(), + sample_size = tune(), + trees = tune(), + min_n = tune(), + tree_depth = tune() + ) + model <- parsnip::set_engine(model, "catboost") + + expect_can_tune_boost_tree(model) + +}) + + +test_that("catboost mtry", { + + hyperparameters <- data.frame(mtry = c(1, 2, 6)) + for(i in 1:nrow(hyperparameters)) { + model <- parsnip::boost_tree(mtry = hyperparameters$mtry[i]) + expect_all_modes_works(model, 'catboost') + } + +}) + +test_that("catboost trees", { + + hyperparameters <- data.frame(trees = c(1, 20, 300)) + for(i in 1:nrow(hyperparameters)) { + model <- parsnip::boost_tree(trees = hyperparameters$trees[i]) + expect_all_modes_works(model, 'catboost') + } + +}) + + +test_that("catboost min_n hiperparameter", { + + hyperparameters <- data.frame(min_n = c(1, 10)) + for(i in 1:nrow(hyperparameters)) { + model <- parsnip::boost_tree(min_n = hyperparameters$min_n[i]) + expect_all_modes_works(model, 'catboost') + } + +}) + +test_that("catboost tree_depth", { + + hyperparameters <- data.frame(tree_depth = c(1, 16)) + for(i in 1:nrow(hyperparameters)) { + model <- parsnip::boost_tree(tree_depth = hyperparameters$tree_depth[i]) + expect_all_modes_works(model, 'catboost') + } + +}) + +test_that("catboost multi_predict", { + model <- parsnip::boost_tree(mtry = 5, trees = 5, mode = "regression") + model <- parsnip::set_engine(model, "catboost") + + expect_multi_predict_works(model) +}) + From 9ca2a81f715e48d0f4af84bac8636f4e5962e447 Mon Sep 17 00:00:00 2001 From: Daniel Falbel Date: Fri, 9 Jul 2021 20:35:37 -0300 Subject: [PATCH 20/39] add a simple lightgbm test --- tests/testthat/test-lightgbm.R | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/testthat/test-lightgbm.R b/tests/testthat/test-lightgbm.R index 96e867a..e1b625c 100644 --- a/tests/testthat/test-lightgbm.R +++ b/tests/testthat/test-lightgbm.R @@ -6,19 +6,19 @@ # }) # # -# test_that('lightgbm alternate objective', { -# skip_if_not_installed("lightgbm") -# -# spec <- boost_tree(mtry = 1, trees = 50, tree_depth = 15, min_n = 1) %>% -# set_engine("lightgbm", objective = "huber") %>% -# set_mode("regression") -# -# lgb_fit <- spec %>% fit(mpg ~ ., data = mtcars) -# -# info <- jsonlite::fromJSON(lightgbm::lgb.dump(lgb_fit$fit)) -# -# expect_equal(info$objective, "huber") -# }) +test_that('lightgbm alternate objective', { + skip_if_not_installed("lightgbm") + + spec <- boost_tree(mtry = 1, trees = 50, tree_depth = 15, min_n = 1) %>% + set_engine("lightgbm", objective = "huber") %>% + set_mode("regression") + + lgb_fit <- spec %>% fit(mpg ~ ., data = mtcars) + + info <- jsonlite::fromJSON(lightgbm::lgb.dump(lgb_fit$fit)) + + expect_equal(info$objective, "huber") +}) # # test_that("lightgbm with tune", { # From 28640fdee9f4325e72968f116957b6a985f8ccb8 Mon Sep 17 00:00:00 2001 From: Daniel Falbel Date: Fri, 9 Jul 2021 21:48:30 -0300 Subject: [PATCH 21/39] enable different test --- tests/testthat/test-lightgbm.R | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/testthat/test-lightgbm.R b/tests/testthat/test-lightgbm.R index e1b625c..ce40eb1 100644 --- a/tests/testthat/test-lightgbm.R +++ b/tests/testthat/test-lightgbm.R @@ -1,24 +1,24 @@ -# test_that("lightgbm", { +test_that("lightgbm", { + + model <- parsnip::boost_tree(mtry = 1, trees = 50, tree_depth = 15, min_n = 1) + + expect_all_modes_works(model, 'lightgbm') +}) # -# model <- parsnip::boost_tree(mtry = 1, trees = 50, tree_depth = 15, min_n = 1) # -# expect_all_modes_works(model, 'lightgbm') -# }) +# test_that('lightgbm alternate objective', { +# skip_if_not_installed("lightgbm") # +# spec <- boost_tree(mtry = 1, trees = 50, tree_depth = 15, min_n = 1) %>% +# set_engine("lightgbm", objective = "huber") %>% +# set_mode("regression") # -test_that('lightgbm alternate objective', { - skip_if_not_installed("lightgbm") - - spec <- boost_tree(mtry = 1, trees = 50, tree_depth = 15, min_n = 1) %>% - set_engine("lightgbm", objective = "huber") %>% - set_mode("regression") - - lgb_fit <- spec %>% fit(mpg ~ ., data = mtcars) - - info <- jsonlite::fromJSON(lightgbm::lgb.dump(lgb_fit$fit)) - - expect_equal(info$objective, "huber") -}) +# lgb_fit <- spec %>% fit(mpg ~ ., data = mtcars) +# +# info <- jsonlite::fromJSON(lightgbm::lgb.dump(lgb_fit$fit)) +# +# expect_equal(info$objective, "huber") +# }) # # test_that("lightgbm with tune", { # From d89aa7e2cf2c7627143edc84c6df9545a7d63d5b Mon Sep 17 00:00:00 2001 From: Daniel Falbel Date: Sat, 10 Jul 2021 09:53:03 -0300 Subject: [PATCH 22/39] try both packages together --- .github/workflows/R-CMD-check.yaml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index f8efc0a..0238bd4 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -24,15 +24,13 @@ jobs: run: | remotes::install_deps(dependencies = TRUE, INSTALL_opts = c("--no-multiarch")) shell: Rscript {0} - - name: catboost + - name: catboost and lightgbm run: | library(catboost) features <- data.frame(feature1 = c(1, 2, 3), feature2 = factor(c('A', 'B', 'C'))) labels <- c(0, 0, 1) train_pool <- catboost.load_pool(data = features, label = labels) - shell: Rscript {0} - - name: lightgbm - run: | + library(lightgbm) data(agaricus.train, package='lightgbm') train <- agaricus.train @@ -44,6 +42,7 @@ jobs: ) , data = dtrain ) + shell: Rscript {0} - name: Check run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--no-multiarch"), error_on = "error", check_dir = "check") From a70d0afd094c0b1344cb40cb3bfa90ffe4d18e27 Mon Sep 17 00:00:00 2001 From: Daniel Falbel Date: Sat, 10 Jul 2021 10:42:52 -0300 Subject: [PATCH 23/39] add the same test that we ran before --- tests/testthat/test-lightgbm.R | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/tests/testthat/test-lightgbm.R b/tests/testthat/test-lightgbm.R index ce40eb1..74565ef 100644 --- a/tests/testthat/test-lightgbm.R +++ b/tests/testthat/test-lightgbm.R @@ -1,9 +1,26 @@ -test_that("lightgbm", { +test_that("simple test", { - model <- parsnip::boost_tree(mtry = 1, trees = 50, tree_depth = 15, min_n = 1) + library(lightgbm) + data(agaricus.train, package='lightgbm') + train <- agaricus.train + dtrain <- lgb.Dataset(train$data, label = train$label) + model <- lgb.cv( + params = list( + objective = "regression" + , metric = "l2" + ) + , data = dtrain + ) - expect_all_modes_works(model, 'lightgbm') + expect_s3_class(model, "lgb.CVBooster") }) + +# test_that("lightgbm", { +# +# model <- parsnip::boost_tree(mtry = 1, trees = 50, tree_depth = 15, min_n = 1) +# +# expect_all_modes_works(model, 'lightgbm') +# }) # # # test_that('lightgbm alternate objective', { From a7faaf8efc73d1651a21b94c78cf119b13707dcd Mon Sep 17 00:00:00 2001 From: Daniel Falbel Date: Sat, 10 Jul 2021 13:55:05 -0300 Subject: [PATCH 24/39] install lightgbm from source --- .github/workflows/R-CMD-check.yaml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 0238bd4..4b28a5a 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -16,21 +16,26 @@ jobs: - name: Install remotes run: install.packages(c("remotes", "rcmdcheck")) shell: Rscript {0} + + - name: Install dev lightgbm + run: | + git clone --recursive https://github.com/microsoft/LightGBM.git + cd LightGBM + sh build-cran-package.sh + R CMD INSTALL lightgbm_3.2.1.99.tar.gz + - name: Install catboost run: | remotes::install_url("https://github.com/catboost/catboost/releases/download/v0.26/catboost-R-Windows-0.26.tgz", INSTALL_opts = c("--no-multiarch")) shell: Rscript {0} - - name: Install dependencies + + - name: Install additional dependencies run: | remotes::install_deps(dependencies = TRUE, INSTALL_opts = c("--no-multiarch")) shell: Rscript {0} + - name: catboost and lightgbm run: | - library(catboost) - features <- data.frame(feature1 = c(1, 2, 3), feature2 = factor(c('A', 'B', 'C'))) - labels <- c(0, 0, 1) - train_pool <- catboost.load_pool(data = features, label = labels) - library(lightgbm) data(agaricus.train, package='lightgbm') train <- agaricus.train From 8f83e891cf1a2b6c3f0d8a139a281b610a4aa721 Mon Sep 17 00:00:00 2001 From: Daniel Falbel Date: Sat, 10 Jul 2021 14:09:23 -0300 Subject: [PATCH 25/39] install from the R session --- .github/workflows/R-CMD-check.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 4b28a5a..8235722 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -22,7 +22,7 @@ jobs: git clone --recursive https://github.com/microsoft/LightGBM.git cd LightGBM sh build-cran-package.sh - R CMD INSTALL lightgbm_3.2.1.99.tar.gz + Rscript -e "install.packages('lightgbm_3.2.1.99.tar.gz', repos = NULL, type='source')" - name: Install catboost run: | From edde84281812b6ffc3a7618f48e63324ed38d22a Mon Sep 17 00:00:00 2001 From: Daniel Falbel Date: Sat, 10 Jul 2021 14:13:51 -0300 Subject: [PATCH 26/39] install lightgbm deps first --- .github/workflows/R-CMD-check.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 8235722..91004d3 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -22,6 +22,7 @@ jobs: git clone --recursive https://github.com/microsoft/LightGBM.git cd LightGBM sh build-cran-package.sh + Rscript -e "install.packages(c('data.table', 'jsonlite'))" Rscript -e "install.packages('lightgbm_3.2.1.99.tar.gz', repos = NULL, type='source')" - name: Install catboost From c7d81b7c3d36759b867b288cafdbd088cb0d389d Mon Sep 17 00:00:00 2001 From: Daniel Falbel Date: Sat, 10 Jul 2021 14:37:47 -0300 Subject: [PATCH 27/39] clone in a different dir to avoid check warnings... --- .github/workflows/R-CMD-check.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 91004d3..0dd559f 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -19,6 +19,7 @@ jobs: - name: Install dev lightgbm run: | + cd .. git clone --recursive https://github.com/microsoft/LightGBM.git cd LightGBM sh build-cran-package.sh @@ -37,6 +38,7 @@ jobs: - name: catboost and lightgbm run: | + library(parsnip) library(lightgbm) data(agaricus.train, package='lightgbm') train <- agaricus.train From e4c05b5c2ec30ad88cf51e654173b4e920bc5968 Mon Sep 17 00:00:00 2001 From: Daniel Falbel Date: Sat, 10 Jul 2021 15:10:50 -0300 Subject: [PATCH 28/39] also add R6 --- .github/workflows/R-CMD-check.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 0dd559f..9989bff 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -23,7 +23,7 @@ jobs: git clone --recursive https://github.com/microsoft/LightGBM.git cd LightGBM sh build-cran-package.sh - Rscript -e "install.packages(c('data.table', 'jsonlite'))" + Rscript -e "install.packages(c('R6', 'data.table', 'jsonlite'))" Rscript -e "install.packages('lightgbm_3.2.1.99.tar.gz', repos = NULL, type='source')" - name: Install catboost From c76e1d1366e4510d417d3cbf0ca1d4f6b1ffb216 Mon Sep 17 00:00:00 2001 From: Daniel Falbel Date: Sat, 10 Jul 2021 15:23:35 -0300 Subject: [PATCH 29/39] move up --- .github/workflows/R-CMD-check.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 9989bff..baef03a 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -17,6 +17,11 @@ jobs: run: install.packages(c("remotes", "rcmdcheck")) shell: Rscript {0} + - name: Install additional dependencies + run: | + remotes::install_deps(dependencies = TRUE, INSTALL_opts = c("--no-multiarch")) + shell: Rscript {0} + - name: Install dev lightgbm run: | cd .. @@ -31,11 +36,6 @@ jobs: remotes::install_url("https://github.com/catboost/catboost/releases/download/v0.26/catboost-R-Windows-0.26.tgz", INSTALL_opts = c("--no-multiarch")) shell: Rscript {0} - - name: Install additional dependencies - run: | - remotes::install_deps(dependencies = TRUE, INSTALL_opts = c("--no-multiarch")) - shell: Rscript {0} - - name: catboost and lightgbm run: | library(parsnip) From fbc773abbcc0d9e2d59c110b943d799266322676 Mon Sep 17 00:00:00 2001 From: Daniel Falbel Date: Sat, 10 Jul 2021 18:35:51 -0300 Subject: [PATCH 30/39] without parsnip --- .github/workflows/R-CMD-check.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index baef03a..ae4712e 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -36,6 +36,20 @@ jobs: remotes::install_url("https://github.com/catboost/catboost/releases/download/v0.26/catboost-R-Windows-0.26.tgz", INSTALL_opts = c("--no-multiarch")) shell: Rscript {0} + - name: catboost and lightgbm + run: | + library(lightgbm) + data(agaricus.train, package='lightgbm') + train <- agaricus.train + dtrain <- lgb.Dataset(train$data, label = train$label) + model <- lgb.cv( + params = list( + objective = "regression" + , metric = "l2" + ) + , data = dtrain + ) + - name: catboost and lightgbm run: | library(parsnip) From 4ad0c7e02c0aa3911fa19a934239229b28620c7b Mon Sep 17 00:00:00 2001 From: Daniel Falbel Date: Sat, 10 Jul 2021 18:53:37 -0300 Subject: [PATCH 31/39] R shell --- .github/workflows/R-CMD-check.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index ae4712e..83f0b56 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -49,6 +49,7 @@ jobs: ) , data = dtrain ) + shell: Rscript {0} - name: catboost and lightgbm run: | From ecec95e372410e81a07a37d47cd42908c83db502 Mon Sep 17 00:00:00 2001 From: Daniel Falbel Date: Tue, 20 Jul 2021 13:42:07 -0300 Subject: [PATCH 32/39] print session Info --- .github/workflows/R-CMD-check.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 83f0b56..67f4e15 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -40,6 +40,7 @@ jobs: run: | library(lightgbm) data(agaricus.train, package='lightgbm') + print(sessionInfo()) train <- agaricus.train dtrain <- lgb.Dataset(train$data, label = train$label) model <- lgb.cv( @@ -56,6 +57,7 @@ jobs: library(parsnip) library(lightgbm) data(agaricus.train, package='lightgbm') + print(sessionInfo()) train <- agaricus.train dtrain <- lgb.Dataset(train$data, label = train$label) model <- lgb.cv( From feaac64f9b9a48c1d3fee71acdfad15b723c2ba2 Mon Sep 17 00:00:00 2001 From: Daniel Falbel Date: Sun, 25 Jul 2021 10:52:38 -0300 Subject: [PATCH 33/39] remove lightgbm before installaing the dev version --- .github/workflows/R-CMD-check.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 67f4e15..2b62131 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -22,6 +22,11 @@ jobs: remotes::install_deps(dependencies = TRUE, INSTALL_opts = c("--no-multiarch")) shell: Rscript {0} + - name: Remove lightgbm + run: | + remove.packages("lightgbm") + shell: Rscript {0} + - name: Install dev lightgbm run: | cd .. From fd3e51f786d528058a4db34aeddef810fcecdc75 Mon Sep 17 00:00:00 2001 From: Daniel Falbel Date: Sun, 1 Aug 2021 08:39:06 -0300 Subject: [PATCH 34/39] try with @jameslamb branch --- .github/workflows/R-CMD-check.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 2b62131..a4a706d 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -30,7 +30,7 @@ jobs: - name: Install dev lightgbm run: | cd .. - git clone --recursive https://github.com/microsoft/LightGBM.git + git clone --recursive https://github.com/microsoft/LightGBM.git --branch fix/network-setup cd LightGBM sh build-cran-package.sh Rscript -e "install.packages(c('R6', 'data.table', 'jsonlite'))" From 6951d1ca9334d7c47944fbb30f3bf2c6b313245a Mon Sep 17 00:00:00 2001 From: Daniel Falbel Date: Thu, 16 Sep 2021 20:34:52 -0300 Subject: [PATCH 35/39] Re-add all tests --- tests/testthat/test-lightgbm.R | 204 ++++++++++++++++----------------- 1 file changed, 102 insertions(+), 102 deletions(-) diff --git a/tests/testthat/test-lightgbm.R b/tests/testthat/test-lightgbm.R index 74565ef..cd1db6f 100644 --- a/tests/testthat/test-lightgbm.R +++ b/tests/testthat/test-lightgbm.R @@ -15,105 +15,105 @@ test_that("simple test", { expect_s3_class(model, "lgb.CVBooster") }) -# test_that("lightgbm", { -# -# model <- parsnip::boost_tree(mtry = 1, trees = 50, tree_depth = 15, min_n = 1) -# -# expect_all_modes_works(model, 'lightgbm') -# }) -# -# -# test_that('lightgbm alternate objective', { -# skip_if_not_installed("lightgbm") -# -# spec <- boost_tree(mtry = 1, trees = 50, tree_depth = 15, min_n = 1) %>% -# set_engine("lightgbm", objective = "huber") %>% -# set_mode("regression") -# -# lgb_fit <- spec %>% fit(mpg ~ ., data = mtcars) -# -# info <- jsonlite::fromJSON(lightgbm::lgb.dump(lgb_fit$fit)) -# -# expect_equal(info$objective, "huber") -# }) -# -# test_that("lightgbm with tune", { -# -# model <- parsnip::boost_tree( -# mtry = 5, -# learn_rate = tune(), -# loss_reduction = tune(), -# sample_size = tune(), -# trees = tune(), -# min_n = tune(), -# tree_depth = tune() -# ) -# model <- parsnip::set_engine(model, "lightgbm") -# -# expect_can_tune_boost_tree(model) -# -# }) -# -# -# test_that("lightgbm mtry", { -# -# hyperparameters <- data.frame(mtry = c(1, 2, 6)) -# for(i in 1:nrow(hyperparameters)) { -# model <- parsnip::boost_tree(mtry = hyperparameters$mtry[i], min_n = 1) -# expect_all_modes_works(model, 'lightgbm') -# } -# -# }) -# -# test_that("lightgbm trees", { -# -# hyperparameters <- data.frame(trees = c(1, 20, 300)) -# for(i in 1:nrow(hyperparameters)) { -# model <- parsnip::boost_tree(trees = hyperparameters$trees[i], min_n = 1) -# expect_all_modes_works(model, 'lightgbm') -# } -# -# }) -# -# -# test_that("lightgbm min_n hyperparameter", { -# -# hyperparameters <- data.frame(min_n = c(1, 10)) -# for(i in 1:nrow(hyperparameters)) { -# model <- parsnip::boost_tree(min_n = hyperparameters$min_n[i]) -# expect_all_modes_works(model, 'lightgbm') -# } -# -# }) -# -# test_that("lightgbm tree_depth", { -# hyperparameters <- data.frame(tree_depth = c(1, 16)) -# for(i in 1:nrow(hyperparameters)) { -# model <- parsnip::boost_tree(tree_depth = hyperparameters$tree_depth[i], min_n = 1) -# expect_all_modes_works(model, 'lightgbm') -# } -# }) -# -# test_that("lightgbm loss_reduction", { -# hyperparameters <- data.frame(loss_reduction = c(0, 0.2, 2)) -# for(i in 1:nrow(hyperparameters)) { -# model <- parsnip::boost_tree(loss_reduction = hyperparameters$loss_reduction[i], min_n = 1) -# expect_all_modes_works(model, 'lightgbm') -# } -# }) -# -# test_that("lightgbm tree_depth", { -# hyperparameters <- data.frame(loss_reduction = c(0, 0.2, 2)) -# for(i in 1:nrow(hyperparameters)) { -# model <- parsnip::boost_tree(loss_reduction = hyperparameters$loss_reduction[i], min_n = 1) -# expect_all_modes_works(model, 'lightgbm') -# } -# }) -# -# test_that("lightgbm multi_predict", { -# model <- parsnip::boost_tree(mtry = 5, trees = 5, mode = "regression", min_n = 1) -# model <- parsnip::set_engine(model, "lightgbm") -# -# expect_multi_predict_works(model) -# }) -# +test_that("lightgbm", { + + model <- parsnip::boost_tree(mtry = 1, trees = 50, tree_depth = 15, min_n = 1) + + expect_all_modes_works(model, 'lightgbm') +}) + + +test_that('lightgbm alternate objective', { + skip_if_not_installed("lightgbm") + + spec <- boost_tree(mtry = 1, trees = 50, tree_depth = 15, min_n = 1) %>% + set_engine("lightgbm", objective = "huber") %>% + set_mode("regression") + + lgb_fit <- spec %>% fit(mpg ~ ., data = mtcars) + + info <- jsonlite::fromJSON(lightgbm::lgb.dump(lgb_fit$fit)) + + expect_equal(info$objective, "huber") +}) + +test_that("lightgbm with tune", { + + model <- parsnip::boost_tree( + mtry = 5, + learn_rate = tune(), + loss_reduction = tune(), + sample_size = tune(), + trees = tune(), + min_n = tune(), + tree_depth = tune() + ) + model <- parsnip::set_engine(model, "lightgbm") + + expect_can_tune_boost_tree(model) + +}) + + +test_that("lightgbm mtry", { + + hyperparameters <- data.frame(mtry = c(1, 2, 6)) + for(i in 1:nrow(hyperparameters)) { + model <- parsnip::boost_tree(mtry = hyperparameters$mtry[i], min_n = 1) + expect_all_modes_works(model, 'lightgbm') + } + +}) + +test_that("lightgbm trees", { + + hyperparameters <- data.frame(trees = c(1, 20, 300)) + for(i in 1:nrow(hyperparameters)) { + model <- parsnip::boost_tree(trees = hyperparameters$trees[i], min_n = 1) + expect_all_modes_works(model, 'lightgbm') + } + +}) + + +test_that("lightgbm min_n hyperparameter", { + + hyperparameters <- data.frame(min_n = c(1, 10)) + for(i in 1:nrow(hyperparameters)) { + model <- parsnip::boost_tree(min_n = hyperparameters$min_n[i]) + expect_all_modes_works(model, 'lightgbm') + } + +}) + +test_that("lightgbm tree_depth", { + hyperparameters <- data.frame(tree_depth = c(1, 16)) + for(i in 1:nrow(hyperparameters)) { + model <- parsnip::boost_tree(tree_depth = hyperparameters$tree_depth[i], min_n = 1) + expect_all_modes_works(model, 'lightgbm') + } +}) + +test_that("lightgbm loss_reduction", { + hyperparameters <- data.frame(loss_reduction = c(0, 0.2, 2)) + for(i in 1:nrow(hyperparameters)) { + model <- parsnip::boost_tree(loss_reduction = hyperparameters$loss_reduction[i], min_n = 1) + expect_all_modes_works(model, 'lightgbm') + } +}) + +test_that("lightgbm tree_depth", { + hyperparameters <- data.frame(loss_reduction = c(0, 0.2, 2)) + for(i in 1:nrow(hyperparameters)) { + model <- parsnip::boost_tree(loss_reduction = hyperparameters$loss_reduction[i], min_n = 1) + expect_all_modes_works(model, 'lightgbm') + } +}) + +test_that("lightgbm multi_predict", { + model <- parsnip::boost_tree(mtry = 5, trees = 5, mode = "regression", min_n = 1) + model <- parsnip::set_engine(model, "lightgbm") + + expect_multi_predict_works(model) +}) + From 490a3aaced9ea4d6a7997b63b3bd8b3142fe5ba7 Mon Sep 17 00:00:00 2001 From: Daniel Falbel Date: Sat, 6 Nov 2021 09:42:56 -0300 Subject: [PATCH 36/39] re-order pandoc --- .github/workflows/R-CMD-check.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index a4a706d..1981aed 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -11,8 +11,11 @@ jobs: runs-on: windows-latest steps: - uses: actions/checkout@v2 - - uses: r-lib/actions/setup-r@master + - uses: r-lib/actions/setup-pandoc@v1 + + - uses: r-lib/actions/setup-r@master + - name: Install remotes run: install.packages(c("remotes", "rcmdcheck")) shell: Rscript {0} From c872c42ca4fc30ccdb0b9820dd6b58a6363aa2b0 Mon Sep 17 00:00:00 2001 From: Daniel Falbel Date: Sat, 6 Nov 2021 09:46:02 -0300 Subject: [PATCH 37/39] use CRAN's lightgbm --- .github/workflows/R-CMD-check.yaml | 48 +----------------------------- 1 file changed, 1 insertion(+), 47 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 1981aed..1c63826 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -25,61 +25,15 @@ jobs: remotes::install_deps(dependencies = TRUE, INSTALL_opts = c("--no-multiarch")) shell: Rscript {0} - - name: Remove lightgbm - run: | - remove.packages("lightgbm") - shell: Rscript {0} - - - name: Install dev lightgbm - run: | - cd .. - git clone --recursive https://github.com/microsoft/LightGBM.git --branch fix/network-setup - cd LightGBM - sh build-cran-package.sh - Rscript -e "install.packages(c('R6', 'data.table', 'jsonlite'))" - Rscript -e "install.packages('lightgbm_3.2.1.99.tar.gz', repos = NULL, type='source')" - - name: Install catboost run: | remotes::install_url("https://github.com/catboost/catboost/releases/download/v0.26/catboost-R-Windows-0.26.tgz", INSTALL_opts = c("--no-multiarch")) shell: Rscript {0} - - name: catboost and lightgbm - run: | - library(lightgbm) - data(agaricus.train, package='lightgbm') - print(sessionInfo()) - train <- agaricus.train - dtrain <- lgb.Dataset(train$data, label = train$label) - model <- lgb.cv( - params = list( - objective = "regression" - , metric = "l2" - ) - , data = dtrain - ) - shell: Rscript {0} - - - name: catboost and lightgbm - run: | - library(parsnip) - library(lightgbm) - data(agaricus.train, package='lightgbm') - print(sessionInfo()) - train <- agaricus.train - dtrain <- lgb.Dataset(train$data, label = train$label) - model <- lgb.cv( - params = list( - objective = "regression" - , metric = "l2" - ) - , data = dtrain - ) - - shell: Rscript {0} - name: Check run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--no-multiarch"), error_on = "error", check_dir = "check") shell: Rscript {0} + - name: Show testthat output if: always() run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true From 2a38bea9260187dc69c2cb2452f6ca4ea150d96d Mon Sep 17 00:00:00 2001 From: Daniel Falbel Date: Sun, 26 Dec 2021 10:57:08 -0300 Subject: [PATCH 38/39] small tweaks to reduce verbosity. --- R/lightgbm.R | 5 +++-- tests/testthat/helper-model.R | 2 +- tests/testthat/test-lightgbm.R | 17 ----------------- 3 files changed, 4 insertions(+), 20 deletions(-) diff --git a/R/lightgbm.R b/R/lightgbm.R index 61ea6f5..9631b5e 100644 --- a/R/lightgbm.R +++ b/R/lightgbm.R @@ -272,7 +272,7 @@ train_lightgbm <- function(x, y, max_depth = 17, num_iterations = 10, learning_r data = prepare_df_lgbm(x), label = y, categorical_feature = categorical_columns(x), - feature_pre_filter = FALSE + params = list(feature_pre_filter = FALSE) ) main_args <- list( @@ -345,7 +345,8 @@ predict_lightgbm_classification_raw <- function(object, new_data, ...) { #' @export predict_lightgbm_regression_numeric <- function(object, new_data, ...) { # train_colnames <- object$fit$.__enclos_env__$private$train_set$get_colnames() - p <- stats::predict(object$fit, prepare_df_lgbm(new_data), reshape = TRUE, predict_disable_shape_check=TRUE, ...) + p <- stats::predict(object$fit, prepare_df_lgbm(new_data), reshape = TRUE, + params = list(predict_disable_shape_check=TRUE), ...) p } diff --git a/tests/testthat/helper-model.R b/tests/testthat/helper-model.R index 42e833a..0403c2e 100644 --- a/tests/testthat/helper-model.R +++ b/tests/testthat/helper-model.R @@ -5,7 +5,7 @@ mtcars_class_binary$vs <- as.factor(mtcars$vs) expect_all_modes_works <- function(model, engine) { if(engine == "lightgbm") { - model <- parsnip::set_engine(model, engine, verbosity = -1L) + model <- parsnip::set_engine(model, engine, verbose = -1L) } else { model <- parsnip::set_engine(model, engine) } diff --git a/tests/testthat/test-lightgbm.R b/tests/testthat/test-lightgbm.R index cd1db6f..1309ffa 100644 --- a/tests/testthat/test-lightgbm.R +++ b/tests/testthat/test-lightgbm.R @@ -1,20 +1,3 @@ -test_that("simple test", { - - library(lightgbm) - data(agaricus.train, package='lightgbm') - train <- agaricus.train - dtrain <- lgb.Dataset(train$data, label = train$label) - model <- lgb.cv( - params = list( - objective = "regression" - , metric = "l2" - ) - , data = dtrain - ) - - expect_s3_class(model, "lgb.CVBooster") -}) - test_that("lightgbm", { model <- parsnip::boost_tree(mtry = 1, trees = 50, tree_depth = 15, min_n = 1) From 7ca3169c5cc209c526407ce628c59752b0ea25ec Mon Sep 17 00:00:00 2001 From: Daniel Falbel Date: Sun, 26 Dec 2021 11:09:03 -0300 Subject: [PATCH 39/39] avoid OOM error in CI --- 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 1309ffa..b3f3c7d 100644 --- a/tests/testthat/test-lightgbm.R +++ b/tests/testthat/test-lightgbm.R @@ -50,7 +50,7 @@ test_that("lightgbm mtry", { test_that("lightgbm trees", { - hyperparameters <- data.frame(trees = c(1, 20, 300)) + hyperparameters <- data.frame(trees = c(1, 20, 50)) for(i in 1:nrow(hyperparameters)) { model <- parsnip::boost_tree(trees = hyperparameters$trees[i], min_n = 1) expect_all_modes_works(model, 'lightgbm')