diff --git a/.github/workflows/test-task-1.yml b/.github/workflows/test-task-1.yml deleted file mode 100644 index cfab11bc..00000000 --- a/.github/workflows/test-task-1.yml +++ /dev/null @@ -1,43 +0,0 @@ -# r cmd check workflow of the mlr3 ecosystem v0.1.0 -# https://github.com/mlr-org/actions -on: - workflow_dispatch: - push: - branches: - - main - pull_request: - branches: - - main - -name: mlr3 & mlr3pipelines change - -jobs: - r-cmd-check: - runs-on: ${{ matrix.config.os }} - - name: ${{ matrix.config.os }} (${{ matrix.config.r }}) - - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - - strategy: - fail-fast: false - matrix: - config: - - {os: ubuntu-latest, r: 'release'} - - steps: - - uses: actions/checkout@v3 - - - name: mlr3 - run: 'echo -e "Remotes:\n mlr-org/mlr3@feat/train-predict,\n mlr-org/mlr3pipelines$fixt/uses_test_task" >> DESCRIPTION' - - - uses: r-lib/actions/setup-r@v2 - with: - r-version: ${{ matrix.config.r }} - - - uses: r-lib/actions/setup-r-dependencies@v2 - with: - extra-packages: any::rcmdcheck - needs: check - - uses: r-lib/actions/check-r-package@v2 diff --git a/.github/workflows/test-task-2.yml b/.github/workflows/test-task-2.yml deleted file mode 100644 index d67df706..00000000 --- a/.github/workflows/test-task-2.yml +++ /dev/null @@ -1,43 +0,0 @@ -# r cmd check workflow of the mlr3 ecosystem v0.1.0 -# https://github.com/mlr-org/actions -on: - workflow_dispatch: - push: - branches: - - main - pull_request: - branches: - - main - -name: mlr3 & mlr3pipelines change - -jobs: - r-cmd-check: - runs-on: ${{ matrix.config.os }} - - name: ${{ matrix.config.os }} (${{ matrix.config.r }}) - - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - - strategy: - fail-fast: false - matrix: - config: - - {os: ubuntu-latest, r: 'release'} - - steps: - - uses: actions/checkout@v3 - - - name: mlr3 - run: 'echo -e "Remotes:\n mlr-org/mlr3@feat/train-predict,\n mlr-org/mlr3pipelines$feat/test-rows" >> DESCRIPTION' - - - uses: r-lib/actions/setup-r@v2 - with: - r-version: ${{ matrix.config.r }} - - - uses: r-lib/actions/setup-r-dependencies@v2 - with: - extra-packages: any::rcmdcheck - needs: check - - uses: r-lib/actions/check-r-package@v2 diff --git a/R/LearnerClassifXgboost.R b/R/LearnerClassifXgboost.R index 51d99b41..b2a3610c 100644 --- a/R/LearnerClassifXgboost.R +++ b/R/LearnerClassifXgboost.R @@ -80,7 +80,9 @@ LearnerClassifXgboost = R6Class("LearnerClassifXgboost", tags = c("train", "hotstart", "internal_tuning"), aggr = crate(function(x) as.integer(ceiling(mean(unlist(x)))), .parent = topenv()), in_tune_fn = crate(function(domain, param_vals) { - assert_true(!is.null(param_vals$early_stopping_rounds), .var.name = "early stopping rounds is set") + if (is.null(param_vals$early_stopping_rounds)) { + stop("Parameter 'early_stopping_rounds' must be set to use internal tuning.") + } assert_integerish(domain$upper, len = 1L, any.missing = FALSE) }, .parent = topenv()), disable_in_tune = list(early_stopping_rounds = NULL) ) diff --git a/R/LearnerRegrXgboost.R b/R/LearnerRegrXgboost.R index 02049af8..98b410a0 100644 --- a/R/LearnerRegrXgboost.R +++ b/R/LearnerRegrXgboost.R @@ -59,7 +59,9 @@ LearnerRegrXgboost = R6Class("LearnerRegrXgboost", tags = c("train", "hotstart", "internal_tuning"), aggr = crate(function(x) as.integer(ceiling(mean(unlist(x)))), .parent = topenv()), in_tune_fn = crate(function(domain, param_vals) { - assert_true(!is.null(param_vals$early_stopping_rounds), .var.name = "early stopping rounds is set") + if (is.null(param_vals$early_stopping_rounds)) { + stop("Parameter 'early_stopping_rounds' must be set to use internal tuning.") + } assert_integerish(domain$upper, len = 1L, any.missing = FALSE) }, .parent = topenv()), disable_in_tune = list(early_stopping_rounds = NULL) ) diff --git a/inst/paramtest/test_paramtest_classif.xgboost.R b/inst/paramtest/test_paramtest_classif.xgboost.R index d00c721b..e87e3d31 100644 --- a/inst/paramtest/test_paramtest_classif.xgboost.R +++ b/inst/paramtest/test_paramtest_classif.xgboost.R @@ -41,8 +41,7 @@ test_that("classif.xgboost", { "eval_metric", # handled by mlr3 "label", # handled by mlr3 "weight", # handled by mlr3 - "nthread", # handled by mlr3 - "early_stopping" # extra parameter of mlr3 + "nthread" # handled by mlr3 ) ParamTest = run_paramtest(learner, fun, exclude, tag = "train") diff --git a/inst/paramtest/test_paramtest_regr.xgboost.R b/inst/paramtest/test_paramtest_regr.xgboost.R index ea7f54d4..baf3493f 100644 --- a/inst/paramtest/test_paramtest_regr.xgboost.R +++ b/inst/paramtest/test_paramtest_regr.xgboost.R @@ -42,7 +42,6 @@ test_that("regr.xgboost", { "label", # handled by mlr3 "weight", # handled by mlr3 "nthread" # handled by mlr3 - "early_stopping" # extra parameter of mlr3 ) ParamTest = run_paramtest(learner, fun, exclude, tag = "train") diff --git a/man/mlr_learners_regr.xgboost.Rd b/man/mlr_learners_regr.xgboost.Rd index 2da77c45..a3ea6d0a 100644 --- a/man/mlr_learners_regr.xgboost.Rd +++ b/man/mlr_learners_regr.xgboost.Rd @@ -106,6 +106,38 @@ lrn("regr.xgboost") xgb_model \tab untyped \tab NULL \tab \tab - \cr } } +\section{Early stopping}{ + +Early stopping can be used to find the optimal number of boosting rounds. +Set \code{early_stopping_rounds} to an integer vaulue to monitor the performance of the model on the validation set while training. +For information on how to configure the valdiation set, see the \emph{Validation} section of \code{\link[mlr3:Learner]{mlr3::Learner}}. +} + +\section{Initial parameter values}{ + +\itemize{ +\item \code{nrounds}: +\itemize{ +\item Actual default: no default. +\item Adjusted default: 1. +\item Reason for change: Without a default construction of the learner +would error. Just setting a nonsense default to workaround this. +\code{nrounds} needs to be tuned by the user. +} +\item \code{nthread}: +\itemize{ +\item Actual value: Undefined, triggering auto-detection of the number of CPUs. +\item Adjusted value: 1. +\item Reason for change: Conflicting with parallelization via \CRANpkg{future}. +} +\item \code{verbose}: +\itemize{ +\item Actual default: 1. +\item Adjusted default: 0. +\item Reason for change: Reduce verbosity. +} +} +} \examples{ \dontrun{ diff --git a/tests/testthat/test_classif_xgboost.R b/tests/testthat/test_classif_xgboost.R index ceadaa5a..47fc5c07 100644 --- a/tests/testthat/test_classif_xgboost.R +++ b/tests/testthat/test_classif_xgboost.R @@ -100,7 +100,7 @@ test_that("validation and inner tuning", { validate = 0.2 ) s = learner$param_set$search_space() - expect_error(learner$param_set$convert_internal_search_space(s), "early stopping") + expect_error(learner$param_set$convert_internal_search_space(s), "Parameter") learner$param_set$set_values(early_stopping_rounds = 10) learner$param_set$disable_internal_tuning("nrounds") expect_equal(learner$param_set$values$early_stopping_rounds, NULL) diff --git a/tests/testthat/test_regr_xgboost.R b/tests/testthat/test_regr_xgboost.R index cc9e8a44..259842e1 100644 --- a/tests/testthat/test_regr_xgboost.R +++ b/tests/testthat/test_regr_xgboost.R @@ -81,7 +81,7 @@ test_that("validation and inner tuning", { validate = 0.2 ) s = learner$param_set$search_space() - expect_error(learner$param_set$convert_internal_search_space(s), "early stopping") + expect_error(learner$param_set$convert_internal_search_space(s), "Parameter") learner$param_set$set_values(early_stopping_rounds = 10) learner$param_set$disable_internal_tuning("nrounds") expect_equal(learner$param_set$values$early_stopping_rounds, NULL)