From a622524407e73283dfa11c6fb9a292dcf2c2e042 Mon Sep 17 00:00:00 2001 From: John Zobolas Date: Fri, 18 Oct 2024 11:05:29 +0200 Subject: [PATCH] Survival learner doc updates + miscellaneous stuff (#385) * remove repeated section * compact refs * disable parallelization for aorsf (default behavior => use 1 core) * add section prediction types * crank first for surv_coxboost learners + times refactoring * fix example bug * fix misspell * remove example (template is used) * add prediction types section in flexsurv + minor doc refactoring * doc refinements * update doc for surv.glmnet learners * refine Breslow doc * update gamboost doc * add min working versions for surv gbm, glmnet and mboost * minor update on surv.gamboost doc + small refactoring * refine surv.glmboost doc * update RWeka doc links * surv doc updates * update doc on the rest of mboost surv learners * update doc on ctree and cforest surv learners * add minimum working version for partykit * correct link * update docs * better doc for surv.penalized * set trace = FALSE for surv.penalized * change crank <=> distr order, fix small bug * add selected_features() for surv.penalized * update doc for surv.penalized * refactor + add a new test for surv.penalized * update doc for surv.penalized * add doc about family and type.measure params * correct prediction types, add breslow distr to surv.prioritylasso * remove predict-tagged params that are not actually used by predict method * add comment on cv.glmnet() params * update doc on prioritylasso learners * add encapsulate method in all learner docs * correct doc for selected_features() method * add example to surv.prioritylasso learner * remove unused parameter: no handing of missing data * explictly use coef method from penalized * fix cv.glmnet() link * minimum version for surv svm * add predict type doc for ssvm * refactor: ssvm * split gamma.mu to two parameters in surv svm * update ssvm tests * update docs (mlr3 => CRAN version 0.20.2) * improve doc for surv.cforest - set cores to 1 explicitly * aorsf: use unique event times for S(t) during predict to be in line with the rest of RSFs * add min working version for penalized * set ntree to 500 as is the default of the package * add min working version for ranger and rfsrc learners * rfsrc survival learner updates * change ntime and ntree defaults * add doc * change doc format * doc update to mlr3 v0.21.0 * small fix in example template * change order of doc sections * add prediction types doc for surv.ranger * correct prediction types doc * refactor akritas: use unique train times in predict + ntime parameter + doc * refactor parametric * use unique train times in predict + ntime parameter * refine doc * change default value for discrete to TRUE * update tests for akritas and parametric * change file name as this learner is now called from survivalmodels * fix styling issues * rename test file * add bagging_by_query param to lightgbm learners * increase lightgbm min version * fix example (importance required a parameter to be set in the learner) * refine don for NA survival estimator * refine styling of doc * fix examples with learner importance * add prediction types doc for DL survival models * small fix in the example * add min working vesion for xgboost * rename doc section to prediction types * correct another example * fix yet another example with importance * Update R/learner_aorsf_surv_aorsf.R Co-authored-by: Sebastian Fischer * use @examplesIf where necessary * refactor => gridify_times() * refine doc: custom mlr3 => initial values across learners * update news --------- Co-authored-by: Sebastian Fischer --- DESCRIPTION | 20 +-- NEWS.md | 15 +++ R/helpers.R | 12 ++ R/learner_BART_surv_bart.R | 7 +- R/learner_CoxBoost_surv_coxboost.R | 28 ++-- R/learner_CoxBoost_surv_cv_coxboost.R | 22 +--- R/learner_RWeka_classif_LMT.R | 2 +- R/learner_abess_classif_abess.R | 7 +- R/learner_aorsf_surv_aorsf.R | 20 +-- R/learner_dbarts_regr_bart.R | 4 +- R/learner_flexsurv_surv_flexible.R | 18 +-- R/learner_gbm_surv_gbm.R | 18 ++- R/learner_glmnet_surv_cv_glmnet.R | 15 ++- R/learner_glmnet_surv_glmnet.R | 15 ++- R/learner_lightgbm_classif_lightgbm.R | 6 +- R/learner_lightgbm_regr_lightgbm.R | 1 + R/learner_mboost_regr_gamboost.R | 3 +- R/learner_mboost_surv_blackboost.R | 41 +++--- R/learner_mboost_surv_gamboost.R | 46 ++++--- R/learner_mboost_surv_glmboost.R | 33 +++-- R/learner_mboost_surv_mboost.R | 33 ++--- R/learner_mgcv_classif_gam.R | 6 +- R/learner_mgcv_regr_gam.R | 3 +- R/learner_partykit_classif_mob.R | 2 +- R/learner_partykit_regr_mob.R | 2 +- R/learner_partykit_surv_cforest.R | 55 ++++---- R/learner_partykit_surv_ctree.R | 8 +- R/learner_penalized_surv_penalized.R | 79 ++++++++---- ...ner_prioritylasso_classif_priority_lasso.R | 5 +- R/learner_prioritylasso_regr_priority_lasso.R | 3 + R/learner_prioritylasso_surv_priority_lasso.R | 122 ++++++++++++------ ...randomForestSRC_classif_imbalanced_rfsrc.R | 25 +++- R/learner_randomForestSRC_classif_rfsrc.R | 42 ++++-- R/learner_randomForestSRC_regr_rfsrc.R | 24 +++- R/learner_randomForestSRC_surv_rfsrc.R | 61 +++++++-- R/learner_randomForest_classif_randomForest.R | 24 +++- R/learner_randomForest_regr_randomForest.R | 24 +++- R/learner_ranger_surv_ranger.R | 41 +++++- R/learner_survival_surv_nelson.R | 12 +- R/learner_survivalmodels_surv_akritas.R | 27 +++- R/learner_survivalmodels_surv_coxtime.R | 7 + R/learner_survivalmodels_surv_deephit.R | 7 + R/learner_survivalmodels_surv_deepsurv.R | 9 +- R/learner_survivalmodels_surv_dnnsurv.R | 7 + R/learner_survivalmodels_surv_loghaz.R | 7 + ... learner_survivalmodels_surv_parametric.R} | 58 +++++---- R/learner_survivalmodels_surv_pchazard.R | 7 + R/learner_survivalsvm_surv_svm.R | 53 ++++++-- R/learner_xgboost_surv_xgboost_aft.R | 3 +- R/learner_xgboost_surv_xgboost_cox.R | 2 +- man-roxygen/example.R | 10 +- man/mlr_learners_classif.AdaBoostM1.Rd | 3 +- man/mlr_learners_classif.C50.Rd | 3 +- man/mlr_learners_classif.IBk.Rd | 3 +- man/mlr_learners_classif.J48.Rd | 3 +- man/mlr_learners_classif.JRip.Rd | 3 +- man/mlr_learners_classif.LMT.Rd | 5 +- man/mlr_learners_classif.OneR.Rd | 3 +- man/mlr_learners_classif.PART.Rd | 3 +- man/mlr_learners_classif.abess.Rd | 9 +- man/mlr_learners_classif.bart.Rd | 1 + man/mlr_learners_classif.bayes_net.Rd | 3 +- man/mlr_learners_classif.catboost.Rd | 1 + man/mlr_learners_classif.cforest.Rd | 1 + man/mlr_learners_classif.ctree.Rd | 1 + man/mlr_learners_classif.decision_stump.Rd | 3 +- man/mlr_learners_classif.decision_table.Rd | 3 +- man/mlr_learners_classif.earth.Rd | 1 + man/mlr_learners_classif.fnn.Rd | 1 + man/mlr_learners_classif.gam.Rd | 13 ++ man/mlr_learners_classif.gamboost.Rd | 1 + man/mlr_learners_classif.gausspr.Rd | 1 + man/mlr_learners_classif.gbm.Rd | 3 +- man/mlr_learners_classif.glmboost.Rd | 1 + man/mlr_learners_classif.glmer.Rd | 1 + man/mlr_learners_classif.imbalanced_rfsrc.Rd | 28 ++-- man/mlr_learners_classif.kstar.Rd | 3 +- man/mlr_learners_classif.ksvm.Rd | 1 + man/mlr_learners_classif.liblinear.Rd | 1 + man/mlr_learners_classif.lightgbm.Rd | 15 +-- man/mlr_learners_classif.logistic.Rd | 3 +- man/mlr_learners_classif.lssvm.Rd | 1 + man/mlr_learners_classif.mob.Rd | 3 + ..._learners_classif.multilayer_perceptron.Rd | 3 +- ...earners_classif.naive_bayes_multinomial.Rd | 3 +- man/mlr_learners_classif.naive_bayes_weka.Rd | 3 +- man/mlr_learners_classif.priority_lasso.Rd | 10 +- man/mlr_learners_classif.randomForest.Rd | 8 +- ...mlr_learners_classif.random_forest_weka.Rd | 3 +- man/mlr_learners_classif.random_tree.Rd | 3 +- man/mlr_learners_classif.reptree.Rd | 3 +- man/mlr_learners_classif.rfsrc.Rd | 28 ++-- man/mlr_learners_classif.rpf.Rd | 1 + man/mlr_learners_classif.sgd.Rd | 3 +- man/mlr_learners_classif.simple_logistic.Rd | 3 +- man/mlr_learners_classif.smo.Rd | 3 +- man/mlr_learners_classif.voted_perceptron.Rd | 3 +- man/mlr_learners_dens.kde_ks.Rd | 1 + man/mlr_learners_dens.locfit.Rd | 1 + man/mlr_learners_dens.logspline.Rd | 1 + man/mlr_learners_dens.mixed.Rd | 3 +- man/mlr_learners_dens.nonpar.Rd | 1 + man/mlr_learners_dens.pen.Rd | 1 + man/mlr_learners_dens.plug.Rd | 1 + man/mlr_learners_dens.spline.Rd | 1 + man/mlr_learners_regr.IBk.Rd | 3 +- man/mlr_learners_regr.M5Rules.Rd | 3 +- man/mlr_learners_regr.abess.Rd | 3 + man/mlr_learners_regr.bart.Rd | 5 +- man/mlr_learners_regr.catboost.Rd | 3 +- man/mlr_learners_regr.cforest.Rd | 1 + man/mlr_learners_regr.ctree.Rd | 1 + man/mlr_learners_regr.cubist.Rd | 3 +- man/mlr_learners_regr.decision_stump.Rd | 3 +- man/mlr_learners_regr.decision_table.Rd | 3 +- man/mlr_learners_regr.earth.Rd | 1 + man/mlr_learners_regr.fnn.Rd | 1 + man/mlr_learners_regr.gam.Rd | 4 +- man/mlr_learners_regr.gamboost.Rd | 4 +- man/mlr_learners_regr.gaussian_processes.Rd | 3 +- man/mlr_learners_regr.gausspr.Rd | 1 + man/mlr_learners_regr.gbm.Rd | 1 + man/mlr_learners_regr.glm.Rd | 1 + man/mlr_learners_regr.glmboost.Rd | 1 + man/mlr_learners_regr.kstar.Rd | 3 +- man/mlr_learners_regr.ksvm.Rd | 1 + man/mlr_learners_regr.liblinear.Rd | 1 + man/mlr_learners_regr.lightgbm.Rd | 4 +- man/mlr_learners_regr.linear_regression.Rd | 3 +- man/mlr_learners_regr.lmer.Rd | 1 + man/mlr_learners_regr.m5p.Rd | 3 +- man/mlr_learners_regr.mars.Rd | 1 + man/mlr_learners_regr.mob.Rd | 3 + ...mlr_learners_regr.multilayer_perceptron.Rd | 3 +- man/mlr_learners_regr.priority_lasso.Rd | 9 ++ man/mlr_learners_regr.randomForest.Rd | 8 +- man/mlr_learners_regr.random_forest_weka.Rd | 3 +- man/mlr_learners_regr.random_tree.Rd | 3 +- man/mlr_learners_regr.reptree.Rd | 3 +- man/mlr_learners_regr.rfsrc.Rd | 28 ++-- man/mlr_learners_regr.rpf.Rd | 1 + man/mlr_learners_regr.rsm.Rd | 1 + man/mlr_learners_regr.rvm.Rd | 1 + man/mlr_learners_regr.sgd.Rd | 3 +- ..._learners_regr.simple_linear_regression.Rd | 3 +- man/mlr_learners_regr.smo_reg.Rd | 3 +- man/mlr_learners_surv.akritas.Rd | 18 ++- man/mlr_learners_surv.aorsf.Rd | 39 +++--- man/mlr_learners_surv.bart.Rd | 12 +- man/mlr_learners_surv.blackboost.Rd | 20 +++ man/mlr_learners_surv.cforest.Rd | 20 +++ man/mlr_learners_surv.coxboost.Rd | 15 ++- man/mlr_learners_surv.coxtime.Rd | 12 ++ man/mlr_learners_surv.ctree.Rd | 12 ++ man/mlr_learners_surv.cv_coxboost.Rd | 27 ++-- man/mlr_learners_surv.cv_glmnet.Rd | 26 ++-- man/mlr_learners_surv.deephit.Rd | 12 ++ man/mlr_learners_surv.deepsurv.Rd | 14 +- man/mlr_learners_surv.dnnsurv.Rd | 12 ++ man/mlr_learners_surv.flexible.Rd | 33 ++--- man/mlr_learners_surv.gamboost.Rd | 23 +++- man/mlr_learners_surv.gbm.Rd | 23 +++- man/mlr_learners_surv.glmboost.Rd | 37 +++--- man/mlr_learners_surv.glmnet.Rd | 28 ++-- man/mlr_learners_surv.loghaz.Rd | 12 ++ man/mlr_learners_surv.mboost.Rd | 20 +++ man/mlr_learners_surv.nelson.Rd | 17 ++- man/mlr_learners_surv.parametric.Rd | 54 ++++---- man/mlr_learners_surv.pchazard.Rd | 12 ++ man/mlr_learners_surv.penalized.Rd | 47 ++++++- man/mlr_learners_surv.priority_lasso.Rd | 58 ++++++++- man/mlr_learners_surv.ranger.Rd | 25 ++-- man/mlr_learners_surv.rfsrc.Rd | 61 ++++++--- man/mlr_learners_surv.svm.Rd | 25 +++- man/mlr_learners_surv.xgboost.aft.Rd | 33 ++--- man/mlr_learners_surv.xgboost.cox.Rd | 17 ++- tests/testthat/test_aorsf_surv_aorsf.R | 1 - ...amtest_prioritylasso_surv_priority_lasso.R | 4 +- ...aramtest_survivalmodels_surv_parametric.R} | 0 .../test_paramtest_survivalsvm_surv_svm.R | 3 +- .../testthat/test_penalized_surv_penalized.R | 19 ++- .../test_survivalmodels_surv_akritas.R | 22 ++++ ... => test_survivalmodels_surv_parametric.R} | 56 +++++--- tests/testthat/test_survivalsvm_surv_svm.R | 2 +- 184 files changed, 1632 insertions(+), 686 deletions(-) rename R/{learner_survival_surv_parametric.R => learner_survivalmodels_surv_parametric.R} (75%) rename tests/testthat/{test_paramtest_survival_surv_parametric.R => test_paramtest_survivalmodels_surv_parametric.R} (100%) rename tests/testthat/{test_survival_surv_parametric.R => test_survivalmodels_surv_parametric.R} (79%) diff --git a/DESCRIPTION b/DESCRIPTION index 55271aaa9..32f1574ac 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -54,8 +54,8 @@ Suggests: FNN, formattable, future, - gbm, - glmnet, + gbm (>= 2.2.2), + glmnet (>= 4.1-6), gss, jsonlite, keras (>= 2.3.0), @@ -63,11 +63,11 @@ Suggests: knitr, ks, LiblineaR, - lightgbm (>= 4.4.0), + lightgbm (>= 4.5.0), lme4, locfit, logspline, - mboost, + mboost (>= 2.9-10), mda, mgcv, mlr3cluster, @@ -78,8 +78,8 @@ Suggests: nnet, np, param6, - partykit, - penalized, + partykit (>= 1.2-21), + penalized (>= 0.9-52), pendensity, plugdensity, pracma, @@ -87,8 +87,8 @@ Suggests: pseudo, randomForest, randomPlantedForest, - randomForestSRC, - ranger, + randomForestSRC (>= 3.3.0), + ranger (>= 0.16.0), remotes, reticulate (>= 1.16), rpart, @@ -101,10 +101,10 @@ Suggests: stats, survival, survivalmodels (>= 0.1.19), - survivalsvm, + survivalsvm (>= 0.0.5), tensorflow (>= 2.0.0), testthat, - xgboost + xgboost (>= 1.7.8.1) Remotes: binderh/CoxBoost, catboost/catboost/catboost/R-package, diff --git a/NEWS.md b/NEWS.md index 1066bdc15..f471e9c43 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,20 @@ # dev +* Add "Prediction types" doc section for all 30 survival learners + make sure it is consistent #347 +* All survival learners have `crank` as main prediction type (and it is always returned) #331 +* Added minimum working version for all survival learners in `DESCRIPTION` file +* Harmonized the use of times points for prediction as much as possible across survival learners #387 + * added `gridify_times()` function to coarse time points + * fixed `surv.parametric` and `surv.akritas` use of `ntime` argument +* `surv.parametric` is now used by default with `discrete = TRUE` (no survival learner returns now `distr6` vectorized distribution by default) +* Doc update for `mlr3` (version `0.21.0`) +* Fixed custom and initial values across all learners documentation pages +* Fixed doc examples that used `learner$importance()` +* Set `n_thread = 1` for `surv.aorsf` and use unique event time points for predicted `S(t)` +* Add `selected_features()` for `surv.penalized` +* Fix `surv.prioritylasso` learner + add `distr` predictions via Breslow #344 +* Survival SVM `gamma.mu` parameter was split to `gamma` and `mu` to enable easier tuning (`surv.svm` learner) + # mlr3extralearners 0.9.0 * Added response (i.e., survival time) prediction to `aorsf` learner diff --git a/R/helpers.R b/R/helpers.R index 04d03dcc7..9cf79d3ee 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -119,3 +119,15 @@ rename = function(x, old, new) { } x } + +# coerce given times points to an `ntime` grid is `ntime` is not NULL, +# otherwise just returns the sorted unique times points +gridify_times = function(times, ntime) { + times = sort(unique(times)) + if (!is.null(ntime)) { + indx = unique(round(seq.int(1, length(times), length.out = ntime))) + times = times[indx] + } + + times +} diff --git a/R/learner_BART_surv_bart.R b/R/learner_BART_surv_bart.R index 0318f6dc0..b37f80004 100644 --- a/R/learner_BART_surv_bart.R +++ b/R/learner_BART_surv_bart.R @@ -6,11 +6,12 @@ #' Fits a Bayesian Additive Regression Trees (BART) learner to right-censored #' survival data. Calls [BART::mc.surv.bart()] from \CRANpkg{BART}. #' -#' @details -#' Two types of prediction are returned for this learner: +#' @section Prediction types: +#' This learner returns two prediction types: #' 1. `distr`: a 3d survival array with observations as 1st dimension, time #' points as 2nd and the posterior draws as 3rd dimension. -#' 2. `crank`: the expected mortality using [mlr3proba::.surv_return]. The parameter +#' Calculated using the internal `predict.survbart()` function. +#' 2. `crank`: the expected mortality using [mlr3proba::.surv_return()]. The parameter #' `which.curve` decides which posterior draw (3rd dimension) will be used for the #' calculation of the expected mortality. Note that the median posterior is #' by default used for the calculation of survival measures that require a `distr` diff --git a/R/learner_CoxBoost_surv_coxboost.R b/R/learner_CoxBoost_surv_coxboost.R index 2405f6b30..76cb4b7dc 100644 --- a/R/learner_CoxBoost_surv_coxboost.R +++ b/R/learner_CoxBoost_surv_coxboost.R @@ -6,6 +6,15 @@ #' Fit a Survival Cox model with a likelihood based boosting algorithm. #' Calls [CoxBoost::CoxBoost()] from package 'CoxBoost'. #' +#' @section Prediction types: +#' This learner returns three prediction types, using the internal `predict.CoxBoost()` function: +#' 1. `lp`: a vector containing the linear predictors (relative risk scores), +#' where each score corresponds to a specific test observation. +#' 2. `crank`: same as `lp`. +#' 3. `distr`: a 2d survival matrix, with observations as rows and time points +#' as columns. The internal transformation uses the Breslow estimator to compute +#' the baseline hazard and compose the survival distributions from the `lp` predictions. +#' #' @template learner #' @templateVar id surv.coxboost #' @@ -18,15 +27,6 @@ #' multiple hyperparameters, \CRANpkg{mlr3tuning} and [LearnerSurvCoxboost] will likely give better #' results. #' -#' Three prediction types are returned for this learner, using the internal -#' `predict.CoxBoost()` function: -#' 1. `lp`: a vector of linear predictors (relative risk scores), one per -#' observation. -#' 2. `crank`: same as `lp`. -#' 3. `distr`: a 2d survival matrix, with observations as rows and time points -#' as columns. The internal transformation uses the Breslow estimator to compose -#' the survival distributions from the `lp` predictions. -#' #' @references #' `r format_bib("binder2009boosting")` #' @@ -60,7 +60,7 @@ LearnerSurvCoxboost = R6Class("LearnerSurvCoxboost", id = "surv.coxboost", packages = c("mlr3extralearners", "CoxBoost", "pracma"), feature_types = c("integer", "numeric"), - predict_types = c("distr", "crank", "lp"), + predict_types = c("crank", "lp", "distr"), param_set = ps, properties = c("weights", "selected_features"), man = "mlr3extralearners::mlr_learners_surv.coxboost", @@ -126,16 +126,16 @@ LearnerSurvCoxboost = R6Class("LearnerSurvCoxboost", .args = pars, type = "lp")) + # all the unique training time points + times = sort(unique(self$model$time)) surv = invoke(predict, self$model, newdata = newdata, .args = pars, type = "risk", - times = sort(unique(self$model$time))) + times = times) - mlr3proba::.surv_return(times = sort(unique(self$model$time)), - surv = surv, - lp = lp) + mlr3proba::.surv_return(times = times, surv = surv, lp = lp) } ) ) diff --git a/R/learner_CoxBoost_surv_cv_coxboost.R b/R/learner_CoxBoost_surv_cv_coxboost.R index 8e5a869c8..0edee3773 100644 --- a/R/learner_CoxBoost_surv_cv_coxboost.R +++ b/R/learner_CoxBoost_surv_cv_coxboost.R @@ -3,10 +3,11 @@ #' @name mlr_learners_surv.cv_coxboost #' #' @description -#' Fits a survival Cox model using likelihood based boosting and interal cross-validation for the +#' Fits a survival Cox model using likelihood based boosting and internal cross-validation for the #' number of steps. #' Calls [CoxBoost::CoxBoost()] or [CoxBoost::cv.CoxBoost()] from package 'CoxBoost'. #' +#' @inheritSection mlr_learners_surv.coxboost Prediction types #' @template learner #' @templateVar id surv.cv_coxboost #' @@ -22,15 +23,6 @@ #' If `penalty == "optimCoxBoostPenalty"` then [CoxBoost::optimCoxBoostPenalty] is used to determine #' the penalty value to be used in [CoxBoost::cv.CoxBoost]. #' -#' Three prediction types are returned for this learner, using the internal -#' `predict.CoxBoost()` function: -#' 1. `lp`: a vector of linear predictors (relative risk scores), one per -#' observation. -#' 2. `crank`: same as `lp`. -#' 2. `distr`: a 2d survival matrix, with observations as rows and time points -#' as columns. The internal transformation uses the Breslow estimator to compose -#' the survival distributions from the `lp` predictions. -#' #' @references #' `r format_bib("binder2009boosting")` #' @@ -77,7 +69,7 @@ LearnerSurvCVCoxboost = R6Class("LearnerSurvCVCoxboost", id = "surv.cv_coxboost", packages = c("mlr3extralearners", "CoxBoost", "pracma"), feature_types = c("integer", "numeric"), - predict_types = c("distr", "crank", "lp"), + predict_types = c("crank", "lp", "distr"), param_set = ps, properties = c("weights", "selected_features"), man = "mlr3extralearners::mlr_learners_surv.cv_coxboost", @@ -189,16 +181,16 @@ LearnerSurvCVCoxboost = R6Class("LearnerSurvCVCoxboost", .args = pars, type = "lp")) + # all the unique training time points + times = sort(unique(self$model$time)) surv = invoke(predict, self$model, newdata = newdata, .args = pars, type = "risk", - times = sort(unique(self$model$time))) + times = times) - mlr3proba::.surv_return(times = sort(unique(self$model$time)), - surv = surv, - lp = lp) + mlr3proba::.surv_return(times = times, surv = surv, lp = lp) } ) ) diff --git a/R/learner_RWeka_classif_LMT.R b/R/learner_RWeka_classif_LMT.R index 42ec26cff..9a34624e2 100644 --- a/R/learner_RWeka_classif_LMT.R +++ b/R/learner_RWeka_classif_LMT.R @@ -9,7 +9,7 @@ #' @template learner #' @templateVar id classif.LMT #' -#' @section CUstom mlr3 parameters: +#' @section Custom mlr3 parameters: #' - `output_debug_info`: #' - original id: output-debug-info #' diff --git a/R/learner_abess_classif_abess.R b/R/learner_abess_classif_abess.R index bda8c307e..a1cdd5195 100644 --- a/R/learner_abess_classif_abess.R +++ b/R/learner_abess_classif_abess.R @@ -10,13 +10,10 @@ #' @template learner #' #' @section Initial parameter values: -#' * `num.threads`: This parameter is initialized to 1 (default is 0) to avoid conflicts with the mlr3 parallelization. -#' -#' @section Custom mlr3 parameters: -#' * `family` - Depending on the task type, if the parameter `family` is `NULL`, it is set to `"binomial"` for binary +#' - `num.threads`: This parameter is initialized to 1 (default is 0) to avoid conflicts with the mlr3 parallelization. +#' - `family`: Depends on the task type, if the parameter `family` is `NULL`, it is set to `"binomial"` for binary #' classification tasks and to `"multinomial"` for multiclass classification problems. #' -#' #' @template seealso_learner #' @template example #' @export diff --git a/R/learner_aorsf_surv_aorsf.R b/R/learner_aorsf_surv_aorsf.R index b123616c5..69628508f 100644 --- a/R/learner_aorsf_surv_aorsf.R +++ b/R/learner_aorsf_surv_aorsf.R @@ -9,13 +9,17 @@ #' principle deal with missing values, the behaviour has to be configured using #' the parameter `na_action`. #' -#' @details +#' @section Initial parameter values: +#' * `n_thread`: This parameter is initialized to 1 (default is 0) to avoid conflicts with the mlr3 parallelization. +#' +#' @section Prediction types: #' This learner returns three prediction types: #' 1. `distr`: a survival matrix in two dimensions, where observations are #' represented in rows and (unique event) time points in columns. +#' Calculated using the internal `predict.ObliqueForest()` function. #' 2. `response`: the restricted mean survival time of each test observation, #' derived from the survival matrix prediction (`distr`). -#' 3. `crank`: the expected mortality using [mlr3proba::.surv_return]. +#' 3. `crank`: the expected mortality using [mlr3proba::.surv_return()]. #' #' @template learner #' @templateVar id surv.aorsf @@ -27,10 +31,7 @@ #' Note that `mtry` and `mtry_ratio` are mutually exclusive. #' #' @references -#' `r format_bib("jaeger_2019")` -#' -#' `r format_bib("jaeger_2022")` -#' +#' `r format_bib("jaeger_2019", "jaeger_2022")` #' #' @template seealso_learner #' @template example @@ -45,7 +46,7 @@ LearnerSurvAorsf = R6Class("LearnerSurvAorsf", n_tree = p_int(default = 500L, lower = 1L, tags = "train"), n_split = p_int(default = 5L, lower = 1L, tags = "train"), n_retry = p_int(default = 3L, lower = 0L, tags = "train"), - n_thread = p_int(default = 0, lower = 0, tags = c("train", "predict")), + n_thread = p_int(default = 0, lower = 0, tags = c("train", "predict", "threads")), pred_aggregate = p_lgl(default = TRUE, tags = "predict"), pred_simplify = p_lgl(default = FALSE, tags = "predict"), oobag = p_lgl(default = FALSE, tags = 'predict'), @@ -81,6 +82,8 @@ LearnerSurvAorsf = R6Class("LearnerSurvAorsf", verbose_progress = p_lgl(default = FALSE, tags = "train"), na_action = p_fct(levels = c("fail", "omit", "impute_meanmode"), default = "fail", tags = "train")) + ps$values = list(n_thread = 1) + super$initialize( id = "surv.aorsf", packages = c("mlr3extralearners", "aorsf", "pracma"), @@ -177,7 +180,8 @@ LearnerSurvAorsf = R6Class("LearnerSurvAorsf", }, .predict = function(task) { pv = self$param_set$get_values(tags = "predict") - utime = task$unique_event_times() # increasing by default + # estimate S(t) on the unique event times from the train set + utime = self$model$event_times surv = mlr3misc::invoke(predict, self$model, new_data = ordered_features(task, self), diff --git a/R/learner_dbarts_regr_bart.R b/R/learner_dbarts_regr_bart.R index 748be7083..0f93d3ef0 100644 --- a/R/learner_dbarts_regr_bart.R +++ b/R/learner_dbarts_regr_bart.R @@ -10,11 +10,11 @@ #' @templateVar id regr.bart #' #' @section Custom mlr3 parameters: -#' * Parameter: offset +#' * Parameter: `offset` #' * The parameter is removed, because only `dbarts::bart2` allows an offset during training, #' and therefore the offset parameter in `dbarts:::predict.bart` is irrelevant for #' `dbarts::dbart`. -#' * Parameter: nchain, combineChains, combinechains +#' * Parameter: `nchain`, `combineChains`, `combinechains` #' * The parameters are removed as parallelization of multiple models is handled by future. #' #' @section Initial parameter values: diff --git a/R/learner_flexsurv_surv_flexible.R b/R/learner_flexsurv_surv_flexible.R index 2d40dc843..87a9ffc79 100644 --- a/R/learner_flexsurv_surv_flexible.R +++ b/R/learner_flexsurv_surv_flexible.R @@ -9,14 +9,14 @@ #' @template learner #' @templateVar id surv.flexible #' -#' @details -#' This learner returns two prediction types: -#' 1. `lp`: a vector of linear predictors (relative risk scores), for each test -#' observation. +#' @section Prediction types: +#' This learner returns three prediction types: +#' 1. `lp`: a vector containing the linear predictors (relative risk scores), +#' where each score corresponds to a specific test observation. #' Calculated using [flexsurv::flexsurvspline()] and the estimated coefficients. -#' For fitted coefficients, \eqn{\beta = (\beta_0,...,\beta_P)}, -#' and covariates \eqn{X^T = (X_0,...,X_P)^T}, where \eqn{X_0}{X0} -#' is a column of \eqn{1}s, the linear predictor (`lp`) is \eqn{lp = \beta X}. +#' For fitted coefficients, \eqn{\hat{\beta} = (\hat{\beta_0},...,\hat{\beta_P})}, +#' and the test data covariates \eqn{X^T = (X_0,...,X_P)^T}, where \eqn{X_0}{X0} +#' is a column of \eqn{1}s, the linear predictor vector is \eqn{lp = \hat{\beta} X^T}. #' 2. `distr`: a survival matrix in two dimensions, where observations are #' represented in rows and time points in columns. #' Calculated using `predict.flexsurvreg()`. @@ -111,8 +111,8 @@ predict_flexsurvreg = function(object, task, learner, ...) { } X = stats::model.matrix(formulate(rhs = task$feature_names), - data = newdata, - xlev = task$levels()) + data = newdata, + xlev = task$levels()) # collect the auxiliary arguments for the fitted object args = object$aux diff --git a/R/learner_gbm_surv_gbm.R b/R/learner_gbm_surv_gbm.R index 62109438b..ff200476b 100644 --- a/R/learner_gbm_surv_gbm.R +++ b/R/learner_gbm_surv_gbm.R @@ -6,13 +6,19 @@ #' Gradient Boosting for Survival Analysis. #' Calls [gbm::gbm()] from \CRANpkg{gbm}. #' +#' @section Prediction types: +#' This learner returns two prediction types, using the internal `predict.gbm()` function: +#' 1. `lp`: a vector containing the linear predictors (relative risk scores), +#' where each score corresponds to a specific test observation. +#' 2. `crank`: same as `lp`. +#' #' @templateVar id surv.gbm #' @template learner #' -#' @section Parameter changes: +#' @section Initial parameter values: #' - `distribution`: -#' - Actual default: "bernoulli" -#' - Adjusted default: "coxph" +#' - Actual default: `"bernoulli"` +#' - Adjusted default: `"coxph"` #' - Reason for change: This is the only distribution available for survival. #' - `keep.data`: #' - Actual default: TRUE @@ -20,9 +26,9 @@ #' - Reason for change: `keep.data = FALSE` saves memory during model fitting. #' - `n.cores`: #' - Actual default: NULL -#' - Adjusted default: 1 +#' - Adjusted default: `1` #' - Reason for change: Suppressing the automatic internal parallelization if -#' `cv.folds` > 0. +#' `cv.folds` > 0 and avoid threading conflicts with \CRANpkg{future}. #' #' @references #' `r format_bib("friedman2002stochastic")` @@ -82,9 +88,7 @@ LearnerSurvGBM = R6Class("LearnerSurvGBM", private = list( .train = function(task) { - # hacky formula construction as gbm fails when "type" argument specified in Surv() - tn = task$target_names lhs = sprintf("Surv(%s, %s)", tn[1L], tn[2L]) f = formulate(lhs, task$feature_names, env = getNamespace("survival")) diff --git a/R/learner_glmnet_surv_cv_glmnet.R b/R/learner_glmnet_surv_cv_glmnet.R index ba087703c..189d58370 100644 --- a/R/learner_glmnet_surv_cv_glmnet.R +++ b/R/learner_glmnet_surv_cv_glmnet.R @@ -6,20 +6,21 @@ #' Generalized linear models with elastic net regularization. #' Calls [glmnet::cv.glmnet()] from package \CRANpkg{glmnet}. #' -#' @section Custom mlr3 parameters: +#' @section Initial parameter values: #' - `family` is set to `"cox"` and cannot be changed. #' -#' @details -#' This learner returns two prediction types: -#' 1. `lp`: a vector of linear predictors (relative risk scores), one per -#' observation. +#' @section Prediction types: +#' This learner returns three prediction types: +#' 1. `lp`: a vector containing the linear predictors (relative risk scores), +#' where each score corresponds to a specific test observation. #' Calculated using [glmnet::predict.cv.glmnet()]. -#' 2. `distr`: a survival matrix in two dimensions, where observations are +#' 2. `crank`: same as `lp`. +#' 3. `distr`: a survival matrix in two dimensions, where observations are #' represented in rows and time points in columns. #' Calculated using [glmnet::survfit.cv.glmnet()]. #' Parameters `stype` and `ctype` relate to how `lp` predictions are transformed #' into survival predictions and are described in [survival::survfit.coxph()]. -#' By default the Breslow estimator is used. +#' By default the Breslow estimator is used for computing the baseline hazard. #' #' @templateVar id surv.cv_glmnet #' @template learner diff --git a/R/learner_glmnet_surv_glmnet.R b/R/learner_glmnet_surv_glmnet.R index 115e686d7..6a9d521f1 100644 --- a/R/learner_glmnet_surv_glmnet.R +++ b/R/learner_glmnet_surv_glmnet.R @@ -6,20 +6,21 @@ #' Generalized linear models with elastic net regularization. #' Calls [glmnet::glmnet()] from package \CRANpkg{glmnet}. #' -#' @section Custom mlr3 parameters: +#' @section Initial parameter values: #' - `family` is set to `"cox"` and cannot be changed. #' -#' @details -#' This learner returns two prediction types: -#' 1. `lp`: a vector of linear predictors (relative risk scores), one per -#' observation. +#' @section Prediction types: +#' This learner returns three prediction types: +#' 1. `lp`: a vector containing the linear predictors (relative risk scores), +#' where each score corresponds to a specific test observation. #' Calculated using [glmnet::predict.coxnet()]. -#' 2. `distr`: a survival matrix in two dimensions, where observations are +#' 2. `crank`: same as `lp`. +#' 3. `distr`: a survival matrix in two dimensions, where observations are #' represented in rows and time points in columns. #' Calculated using [glmnet::survfit.coxnet()]. #' Parameters `stype` and `ctype` relate to how `lp` predictions are transformed #' into survival predictions and are described in [survival::survfit.coxph()]. -#' By default the Breslow estimator is used. +#' By default the Breslow estimator is used for computing the baseline hazard. #' #' **Caution**: This learner is different to learners calling [glmnet::cv.glmnet()] #' in that it does not use the internal optimization of parameter `lambda`. diff --git a/R/learner_lightgbm_classif_lightgbm.R b/R/learner_lightgbm_classif_lightgbm.R index f9da073bf..79f9de0f9 100644 --- a/R/learner_lightgbm_classif_lightgbm.R +++ b/R/learner_lightgbm_classif_lightgbm.R @@ -20,10 +20,9 @@ #' * Actual default: 1L #' * Initial value: -1L #' * Reason for change: Prevents accidental conflicts with mlr messaging system. -#' -#' @section Custom mlr3 defaults: #' * `objective`: -#' Depending if the task is binary / multiclass, the default is `"binary"` or `"multiclasss"`. +#' * Depends on the task: if binary classification, then this parameter is set to +#' `"binary"`, otherwise `"multiclasss"` and cannot be changed. #' #' @section Custom mlr3 parameters: #' * `num_class`: @@ -91,6 +90,7 @@ LearnerClassifLightGBM = R6Class("LearnerClassifLightGBM", neg_bagging_fraction = p_dbl(default = 1.0, lower = 0.0, upper = 1.0, tags = "train"), bagging_freq = p_int(default = 0L, lower = 0L, tags = "train"), bagging_seed = p_int(default = 3L, tags = "train"), + bagging_by_query = p_lgl(default = FALSE, tags = "train"), feature_fraction = p_dbl(default = 1.0, lower = 0.0, upper = 1.0, tags = "train"), feature_fraction_bynode = p_dbl(default = 1.0, lower = 0.0, upper = 1.0, tags = "train"), feature_fraction_seed = p_int(default = 2L, tags = "train"), diff --git a/R/learner_lightgbm_regr_lightgbm.R b/R/learner_lightgbm_regr_lightgbm.R index 9872ca1ee..4b8fb8e73 100644 --- a/R/learner_lightgbm_regr_lightgbm.R +++ b/R/learner_lightgbm_regr_lightgbm.R @@ -78,6 +78,7 @@ LearnerRegrLightGBM = R6Class("LearnerRegrLightGBM", bagging_fraction = p_dbl(default = 1.0, lower = 0.0, upper = 1.0, tags = "train"), bagging_freq = p_int(default = 0L, lower = 0L, tags = "train"), bagging_seed = p_int(default = 3L, tags = "train"), + bagging_by_query = p_lgl(default = FALSE, tags = "train"), feature_fraction = p_dbl(default = 1.0, lower = 0.0, upper = 1.0, tags = "train"), feature_fraction_bynode = p_dbl(default = 1.0, lower = 0.0, upper = 1.0, tags = "train"), feature_fraction_seed = p_int(default = 2L, tags = "train"), diff --git a/R/learner_mboost_regr_gamboost.R b/R/learner_mboost_regr_gamboost.R index 2e82153ed..629dc3786 100644 --- a/R/learner_mboost_regr_gamboost.R +++ b/R/learner_mboost_regr_gamboost.R @@ -15,8 +15,9 @@ #' @export #' @template seealso_learner #' @examples +#' # Define the Learner #' learner = lrn("regr.gamboost", baselearner = "bols") -#' learner +#' print(learner) LearnerRegrGAMBoost = R6Class("LearnerRegrGAMBoost", inherit = LearnerRegr, public = list( diff --git a/R/learner_mboost_surv_blackboost.R b/R/learner_mboost_surv_blackboost.R index 00b3f08d9..be013722e 100644 --- a/R/learner_mboost_surv_blackboost.R +++ b/R/learner_mboost_surv_blackboost.R @@ -6,6 +6,20 @@ #' Gradient boosting with regression trees for survival analysis. #' Calls [mboost::blackboost()] from \CRANpkg{mboost}. #' +#' @section Prediction types: +#' This learner returns two to three prediction types: +#' 1. `lp`: a vector containing the linear predictors (relative risk scores), +#' where each score corresponds to a specific test observation. +#' Calculated using [mboost::predict.blackboost()]. +#' If the `family` parameter is not `"coxph"`, `-lp` is returned, since non-coxph +#' families represent AFT-style distributions where lower `lp` values indicate higher risk. +#' 2. `crank`: same as `lp`. +#' 3. `distr`: a survival matrix in two dimensions, where observations are +#' represented in rows and time points in columns. +#' Calculated using [mboost::survFit()]. +#' This prediction type is present only when the `family` distribution parameter +#' is equal to `"coxph"` (default). +#' By default the Breslow estimator is used for computing the baseline hazard. #' #' @template learner #' @templateVar id surv.blackboost @@ -87,7 +101,7 @@ LearnerSurvBlackBoost = R6Class("LearnerSurvBlackBoost", id = "surv.blackboost", param_set = ps, feature_types = c("integer", "numeric", "factor"), - predict_types = c("distr", "crank", "lp"), + predict_types = c("crank", "lp", "distr"), properties = "weights", packages = c("mlr3extralearners", "mboost", "pracma"), man = "mlr3extralearners::mlr_learners_surv.blackboost", @@ -171,29 +185,22 @@ LearnerSurvBlackBoost = R6Class("LearnerSurvBlackBoost", pars = self$param_set$get_values(tags = "predict") newdata = ordered_features(task, self) # predict linear predictor - lp = as.numeric(invoke(predict, self$model, newdata = newdata, type = "link", - .args = pars - )) + lp = as.numeric( + invoke(predict, + self$model, + newdata = newdata, + type = "link", + .args = pars) + ) # predict survival if (is.null(self$param_set$values$family) || self$param_set$values$family == "coxph") { + # uses Breslow estimator internally survfit = invoke(mboost::survFit, self$model, newdata = newdata) - - mlr3proba::.surv_return(times = survfit$time, - surv = t(survfit$surv), - lp = lp) + mlr3proba::.surv_return(times = survfit$time, surv = t(survfit$surv), lp = lp) } else { mlr3proba::.surv_return(lp = -lp) } - - - # FIXME - RE-ADD ONCE INTERPRETATION IS CLEAR - # response = NULL - # if (!is.null(self$param_set$values$family)) { - # if (self$param_set$values$family %in% c("weibull", "loglog", "lognormal", "gehan")) { - # response = exp(lp) - # } - # } } ) ) diff --git a/R/learner_mboost_surv_gamboost.R b/R/learner_mboost_surv_gamboost.R index 5bac8de86..bf76820a5 100644 --- a/R/learner_mboost_surv_gamboost.R +++ b/R/learner_mboost_surv_gamboost.R @@ -9,15 +9,26 @@ #' @template learner #' @templateVar id surv.gamboost #' -#' @details -#' `distr` prediction made by [mboost::survFit()]. +#' @section Prediction types: +#' This learner returns two to three prediction types: +#' 1. `lp`: a vector containing the linear predictors (relative risk scores), +#' where each score corresponds to a specific test observation. +#' Calculated using [mboost::predict.gamboost()]. +#' If the `family` parameter is not `"coxph"`, `-lp` is returned, since non-coxph +#' families represent AFT-style distributions where lower `lp` values indicate higher risk. +#' 2. `crank`: same as `lp`. +#' 3. `distr`: a survival matrix in two dimensions, where observations are +#' represented in rows and time points in columns. +#' Calculated using [mboost::survFit()]. +#' This prediction type is present only when the `family` distribution parameter +#' is equal to `"coxph"` (default). +#' By default the Breslow estimator is used for computing the baseline hazard. #' #' @references #' `r format_bib("buhlmann2003boosting")` #' #' @export #' @template seealso_learner -#' @examples #' @template simple_example LearnerSurvGAMBoost = R6Class("LearnerSurvGAMBoost", inherit = mlr3proba::LearnerSurv, @@ -58,7 +69,7 @@ LearnerSurvGAMBoost = R6Class("LearnerSurvGAMBoost", id = "surv.gamboost", param_set = ps, feature_types = c("integer", "numeric", "factor", "logical"), - predict_types = c("distr", "crank", "lp"), + predict_types = c("crank", "lp", "distr"), properties = c("weights", "importance", "selected_features"), packages = c("mlr3extralearners", "mboost", "pracma"), man = "mlr3extralearners::mlr_learners_surv.gamboost", @@ -139,7 +150,6 @@ LearnerSurvGAMBoost = R6Class("LearnerSurvGAMBoost", pars = pars[!(names(pars) %in% formalArgs(mboost::Cindex))] pars = pars[!(names(pars) %in% c("family", "custom.family"))] - with_package("mboost", { invoke(mboost::gamboost, formula = task$formula(task$feature_names), @@ -151,30 +161,24 @@ LearnerSurvGAMBoost = R6Class("LearnerSurvGAMBoost", pars = self$param_set$get_values(tags = "predict") newdata = ordered_features(task, self) # predict linear predictor - lp = as.numeric(invoke(predict, self$model, newdata = newdata, type = "link", - .args = pars - )) + lp = as.numeric( + invoke(predict, + self$model, + newdata = newdata, + type = "link", + .args = pars) + ) # predict survival if (is.null(self$param_set$values$family) || self$param_set$values$family == "coxph") { + # uses Breslow estimator internally survfit = invoke(mboost::survFit, self$model, newdata = newdata) - - mlr3proba::.surv_return(times = survfit$time, - surv = t(survfit$surv), - lp = lp) + mlr3proba::.surv_return(times = survfit$time, surv = t(survfit$surv), lp = lp) } else { mlr3proba::.surv_return(lp = -lp) } - - - # FIXME - RE-ADD ONCE INTERPRETATION IS CLEAR - # response = NULL - # if (!is.null(self$param_set$values$family)) { - # if (self$param_set$values$family %in% c("weibull", "loglog", "lognormal", "gehan")) { - # response = exp(lp) - # } - # } } ) ) + .extralrns_dict$add("surv.gamboost", LearnerSurvGAMBoost) diff --git a/R/learner_mboost_surv_glmboost.R b/R/learner_mboost_surv_glmboost.R index 102ac302d..8bf86070b 100644 --- a/R/learner_mboost_surv_glmboost.R +++ b/R/learner_mboost_surv_glmboost.R @@ -9,18 +9,20 @@ #' @template learner #' @templateVar id surv.glmboost #' -#' @details -#' This learner returns up to three prediction types: -#' 1. `crank`: same as `lp`. -#' 2. `lp`: a vector of linear predictors (relative risk scores), one per -#' observation. +#' @section Prediction types: +#' This learner returns two to three prediction types: +#' 1. `lp`: a vector containing the linear predictors (relative risk scores), +#' where each score corresponds to a specific test observation. #' Calculated using [mboost::predict.glmboost()]. -#' 3. `distr`: a survival matrix in two dimensions, where rows are observations -#' and columns are the time points. -#' This predict type is returned only when the `family` parameter is set to -#' `"coxph"` (which is the default). -#' Calculated using [mboost::survFit()] which uses the Breslow estimator for the -#' baseline hazard function. +#' If the `family` parameter is not `"coxph"`, `-lp` is returned, since non-coxph +#' families represent AFT-style distributions where lower `lp` values indicate higher risk. +#' 2. `crank`: same as `lp`. +#' 3. `distr`: a survival matrix in two dimensions, where observations are +#' represented in rows and time points in columns. +#' Calculated using [mboost::survFit()]. +#' This prediction type is present only when the `family` distribution parameter +#' is equal to `"coxph"` (default). +#' By default the Breslow estimator is used for computing the baseline hazard. #' #' @references #' `r format_bib("buhlmann2003boosting")` @@ -209,9 +211,12 @@ LearnerSurvGLMBoost = R6Class("LearnerSurvGLMBoost", # predict linear predictor pars = self$param_set$get_values(tags = "predict") lp = as.numeric( - invoke(predict, self$model, newdata = newdata, type = "link", - .args = pars - )) + invoke(predict, + self$model, + newdata = newdata, + type = "link", + .args = pars) + ) # predict survival if (is.null(self$param_set$values$family) || self$param_set$values$family == "coxph") { diff --git a/R/learner_mboost_surv_mboost.R b/R/learner_mboost_surv_mboost.R index 73d5b92b9..a89d525d1 100644 --- a/R/learner_mboost_surv_mboost.R +++ b/R/learner_mboost_surv_mboost.R @@ -6,6 +6,21 @@ #' Model-based boosting for survival analysis. #' Calls [mboost::mboost()] from \CRANpkg{mboost}. #' +#' @section Prediction types: +#' This learner returns two to three prediction types: +#' 1. `lp`: a vector containing the linear predictors (relative risk scores), +#' where each score corresponds to a specific test observation. +#' Calculated using [mboost::predict.mboost()]. +#' If the `family` parameter is not `"coxph"`, `-lp` is returned, since non-coxph +#' families represent AFT-style distributions where lower `lp` values indicate higher risk. +#' 2. `crank`: same as `lp`. +#' 3. `distr`: a survival matrix in two dimensions, where observations are +#' represented in rows and time points in columns. +#' Calculated using [mboost::survFit()]. +#' This prediction type is present only when the `family` distribution parameter +#' is equal to `"coxph"` (default). +#' By default the Breslow estimator is used for computing the baseline hazard. +#' #' @template learner #' @templateVar id surv.mboost #' @@ -57,7 +72,7 @@ LearnerSurvMBoost = R6Class("LearnerSurvMBoost", id = "surv.mboost", param_set = ps, feature_types = c("integer", "numeric", "factor", "logical"), - predict_types = c("distr", "crank", "lp"), + predict_types = c("crank", "lp", "distr"), properties = c("weights", "importance", "selected_features"), packages = c("mlr3extralearners", "mboost"), man = "mlr3extralearners::mlr_learners_surv.mboost", @@ -145,30 +160,18 @@ LearnerSurvMBoost = R6Class("LearnerSurvMBoost", }, .predict = function(task) { - newdata = ordered_features(task, self) # predict linear predictor lp = as.numeric(invoke(predict, self$model, newdata = newdata, type = "link")) # predict survival if (is.null(self$param_set$values$family) || self$param_set$values$family == "coxph") { + # uses Breslow estimator internally survfit = invoke(mboost::survFit, self$model, newdata = newdata) - - mlr3proba::.surv_return(times = survfit$time, - surv = t(survfit$surv), - lp = lp) + mlr3proba::.surv_return(times = survfit$time, surv = t(survfit$surv), lp = lp) } else { mlr3proba::.surv_return(lp = -lp) } - - - # FIXME - RE-ADD ONCE INTERPRETATION IS CLEAR - # response = NULL - # if (!is.null(self$param_set$values$family)) { - # if (self$param_set$values$family %in% c("weibull", "loglog", "lognormal", "gehan")) { - # response = exp(lp) - # } - # } } ) ) diff --git a/R/learner_mgcv_classif_gam.R b/R/learner_mgcv_classif_gam.R index fb602ea61..a2919b593 100644 --- a/R/learner_mgcv_classif_gam.R +++ b/R/learner_mgcv_classif_gam.R @@ -22,13 +22,13 @@ #' @references #' `r format_bib("hastie2017generalized", "wood2012mgcv")` #' -#' @examples +#' @examplesIf requireNamespace("mgcv", quietly = TRUE) #' # simple example #' t = mlr3::tsk("spam")$filter(1:1000) #' l = mlr3::lrn("classif.gam") #' l$param_set$set_values( -#' formula = type ~ s(george, k = 3) + s(charDollar, k = 3) + s(edu) -#' ') +#' formula = type ~ s(george, k = 3) + s(charDollar, k = 3) + s(edu) +#' ) #' l$train(t) #' l$model #' @export diff --git a/R/learner_mgcv_regr_gam.R b/R/learner_mgcv_regr_gam.R index 182309ee4..bc6b8b9cb 100644 --- a/R/learner_mgcv_regr_gam.R +++ b/R/learner_mgcv_regr_gam.R @@ -19,8 +19,7 @@ #' @references #' `r format_bib("hastie2017generalized", "wood2012mgcv")` #' -#' @examples -#' +#' @examplesIf requireNamespace("mgcv", quietly = TRUE) #' # simple example #' t = mlr3::tsk("mtcars") #' l = mlr3::lrn("regr.gam") diff --git a/R/learner_partykit_classif_mob.R b/R/learner_partykit_classif_mob.R index 9b09e2ebe..7a52138be 100644 --- a/R/learner_partykit_classif_mob.R +++ b/R/learner_partykit_classif_mob.R @@ -14,7 +14,7 @@ #' #' @export #' @template seealso_learner -#' @examples +#' @examplesIf requireNamespace("partykit", quietly = TRUE) #' library(mlr3) #' logit_ = function(y, x, start = NULL, weights = NULL, offset = NULL, ...) { #' glm(y ~ 1, family = binomial, start = start, ...) diff --git a/R/learner_partykit_regr_mob.R b/R/learner_partykit_regr_mob.R index 7a48f482b..7d5a1c55c 100644 --- a/R/learner_partykit_regr_mob.R +++ b/R/learner_partykit_regr_mob.R @@ -14,7 +14,7 @@ #' #' @export #' @template seealso_learner -#' @examples +#' @examplesIf requireNamespace("partykit", quietly = TRUE) #' library(mlr3) #' lm_ = function(y, x, start = NULL, weights = NULL, offset = NULL, ...) { #' lm(y ~ 1, ...) diff --git a/R/learner_partykit_surv_cforest.R b/R/learner_partykit_surv_cforest.R index 30bdcffd6..933ef309e 100644 --- a/R/learner_partykit_surv_cforest.R +++ b/R/learner_partykit_surv_cforest.R @@ -6,11 +6,22 @@ #' A random forest based on conditional inference trees ([ctree][partykit::ctree]). #' Calls [partykit::cforest()] from \CRANpkg{partykit}. #' +#' @section Prediction types: +#' This learner returns two prediction types: +#' 1. `distr`: a survival matrix in two dimensions, where observations are +#' represented in rows and time points in columns. +#' Calculated using the internal [partykit::predict.cforest()] function. +#' 2. `crank`: the expected mortality using [mlr3proba::.surv_return()]. +#' #' @template learner #' @templateVar id surv.cforest #' #' @inheritSection mlr_learners_classif.cforest Custom mlr3 parameters #' +#' @section Initial parameter values: +#' * `cores`: This parameter is initialized to 1 (default is `NULL`) to avoid +#' threading conflicts with \CRANpkg{future}. +#' #' @references #' `r format_bib("hothorn_2015", "hothorn_2006")` #' @@ -31,14 +42,12 @@ LearnerSurvCForest = R6Class("LearnerSurvCForest", ps = ps( ntree = p_int(default = 500L, lower = 1L, tags = "train"), replace = p_lgl(default = FALSE, tags = "train"), - fraction = p_dbl(default = 0.632, lower = 0, upper = 1, - tags = "train"), - mtry = p_int(lower = 0L, special_vals = list(Inf), - tags = "train"), # default actually "ceiling(sqrt(nvar))" + fraction = p_dbl(default = 0.632, lower = 0, upper = 1, tags = "train"), + # mtry default is actually `ceiling(sqrt(nvar))` + mtry = p_int(lower = 0L, special_vals = list(Inf), tags = "train"), mtryratio = p_dbl(lower = 0, upper = 1, tags = "train"), applyfun = p_uty(tags = c("train", "importance")), - cores = p_int(default = NULL, special_vals = list(NULL), - tags = c("train", "importance", "threads")), + cores = p_int(default = NULL, special_vals = list(NULL), tags = c("train", "importance", "threads")), trace = p_lgl(default = FALSE, tags = "train"), offset = p_uty(tags = "train"), cluster = p_uty(tags = "train"), @@ -46,33 +55,28 @@ LearnerSurvCForest = R6Class("LearnerSurvCForest", scores = p_uty(tags = "train"), teststat = p_fct(default = "quadratic", - levels = c("quadratic", "maximum"), tags = "train"), + levels = c("quadratic", "maximum"), tags = "train"), splitstat = p_fct(default = "quadratic", - levels = c("quadratic", "maximum"), tags = "train"), + levels = c("quadratic", "maximum"), tags = "train"), splittest = p_lgl(default = FALSE, tags = "train"), testtype = p_fct(default = "Univariate", - levels = c("Bonferroni", "MonteCarlo", "Univariate", "Teststatistic"), - tags = "train"), + levels = c("Bonferroni", "MonteCarlo", "Univariate", "Teststatistic"), + tags = "train"), nmax = p_uty(tags = "train"), - alpha = p_dbl(default = 0.05, lower = 0, upper = 1, - tags = "train"), - mincriterion = p_dbl(default = 0.95, lower = 0, upper = 1, - tags = "train"), + alpha = p_dbl(default = 0.05, lower = 0, upper = 1, tags = "train"), + mincriterion = p_dbl(default = 0.95, lower = 0, upper = 1, tags = "train"), logmincriterion = p_dbl(default = log(0.95), tags = "train"), minsplit = p_int(lower = 1L, default = 20L, tags = "train"), minbucket = p_int(lower = 1L, default = 7L, tags = "train"), - minprob = p_dbl(default = 0.01, lower = 0, upper = 1, - tags = "train"), + minprob = p_dbl(default = 0.01, lower = 0, upper = 1, tags = "train"), stump = p_lgl(default = FALSE, tags = "train"), lookahead = p_lgl(default = FALSE, tags = "train"), MIA = p_lgl(default = FALSE, tags = "train"), nresample = p_int(default = 9999L, lower = 1L, tags = "train"), - tol = p_dbl(default = sqrt(.Machine$double.eps), lower = 0, - tags = "train"), + tol = p_dbl(default = sqrt(.Machine$double.eps), lower = 0, tags = "train"), maxsurrogate = p_int(default = 0L, lower = 0L, tags = "train"), numsurrogate = p_lgl(default = FALSE, tags = "train"), - maxdepth = p_int(default = Inf, lower = 0L, - special_vals = list(Inf), tags = "train"), + maxdepth = p_int(default = Inf, lower = 0L, special_vals = list(Inf), tags = "train"), multiway = p_lgl(default = FALSE, tags = "train"), splittry = p_int(default = 2L, lower = 0L, tags = "train"), intersplit = p_lgl(default = FALSE, tags = "train"), @@ -80,8 +84,7 @@ LearnerSurvCForest = R6Class("LearnerSurvCForest", caseweights = p_lgl(default = TRUE, tags = "train"), saveinfo = p_lgl(default = FALSE, tags = "train"), update = p_lgl(default = FALSE, tags = "train"), - splitflavour = p_fct(default = "ctree", - levels = c("ctree", "exhaustive"), tags = "train"), + splitflavour = p_fct(default = "ctree", levels = c("ctree", "exhaustive"), tags = "train"), maxvar = p_int(lower = 1L, tags = "train"), # predict; missing FUN and simplify (not needed here) @@ -101,8 +104,7 @@ LearnerSurvCForest = R6Class("LearnerSurvCForest", releps = p_dbl(default = 0, lower = 0, tags = "train") ) - ps$add_dep("nresample", on = "testtype", - cond = CondEqual$new("MonteCarlo")) + ps$add_dep("nresample", on = "testtype", cond = CondEqual$new("MonteCarlo")) # ps$add_dep("nperm", on = "conditional", cond = CondEqual$new(TRUE)) # ps$add_dep("threshold", on = "conditional", cond = CondEqual$new(TRUE)) @@ -112,11 +114,14 @@ LearnerSurvCForest = R6Class("LearnerSurvCForest", ps$values$mincriterion = 0 ps$values$saveinfo = FALSE + # set cores to 1 + ps$values$cores = 1 + super$initialize( id = "surv.cforest", param_set = ps, # can also predict weights, node, but not really useful here - predict_types = c("distr", "crank"), + predict_types = c("crank", "distr"), feature_types = c("integer", "numeric", "factor", "ordered"), properties = c("weights"), packages = c("mlr3extralearners", "partykit", "sandwich", "coin"), diff --git a/R/learner_partykit_surv_ctree.R b/R/learner_partykit_surv_ctree.R index aed661d0a..839a69831 100644 --- a/R/learner_partykit_surv_ctree.R +++ b/R/learner_partykit_surv_ctree.R @@ -6,6 +6,12 @@ #' Survival Partition Tree where a significance test is used to determine the univariate splits. #' Calls [partykit::ctree()] from \CRANpkg{partykit}. #' +#' @section Prediction types: +#' This learner returns two prediction types: +#' 1. `distr`: a survival matrix in two dimensions, where observations are +#' represented in rows and time points in columns. +#' Calculated using the internal [partykit::predict.party()] function. +#' 2. `crank`: the expected mortality using [mlr3proba::.surv_return()]. #' #' @template learner #' @templateVar id surv.ctree @@ -82,7 +88,7 @@ LearnerSurvCTree = R6Class("LearnerSurvCTree", id = "surv.ctree", packages = c("mlr3extralearners", "partykit", "coin", "sandwich"), feature_types = c("integer", "numeric", "factor", "ordered"), - predict_types = c("distr", "crank"), + predict_types = c("crank", "distr"), param_set = ps, properties = "weights", man = "mlr3extralearners::mlr_learners_surv.ctree", diff --git a/R/learner_penalized_surv_penalized.R b/R/learner_penalized_surv_penalized.R index b9e9b02ce..062666695 100644 --- a/R/learner_penalized_surv_penalized.R +++ b/R/learner_penalized_surv_penalized.R @@ -1,11 +1,23 @@ -#' @title Survival L1 and L2 Penalized Regression Learner +#' @title Survival L1 and L2 Penalized Cox Learner #' @author RaphaelS1 #' @name mlr_learners_surv.penalized #' #' @description -#' Penalized (L1 and L2) generalized linear models. +#' Penalized (L1 and L2) Cox Proportional Hazards model. #' Calls [penalized::penalized()] from \CRANpkg{penalized}. #' +#' @section Prediction types: +#' This learner returns two prediction types: +#' 1. `distr`: a survival matrix in two dimensions, where observations are +#' represented in rows and time points in columns. +#' Calculated using the internal [penalized::predict()] function. +#' By default the Breslow estimator [penalized::breslow()] is used for computing +#' the baseline hazard. +#' 2. `crank`: the expected mortality using [mlr3proba::.surv_return()]. +#' +#' @section Initial parameter values: +#' - `trace` is set to `"FALSE"` to disable printing output during model training. +#' #' @template learner #' @templateVar id surv.penalized #' @@ -13,7 +25,7 @@ #' The `penalized` and `unpenalized` arguments in the learner are implemented slightly #' differently than in [penalized::penalized()]. Here, there is no parameter for `penalized` but #' instead it is assumed that every variable is penalized unless stated in the `unpenalized` -#' parameter, see examples. +#' parameter. #' #' @references #' `r format_bib("goeman2010l1")` @@ -43,37 +55,55 @@ LearnerSurvPenalized = R6Class("LearnerSurvPenalized", trace = p_lgl(default = TRUE, tags = "train") ) + ps$values = list(trace = FALSE) + super$initialize( id = "surv.penalized", packages = c("mlr3extralearners", "penalized", "pracma"), feature_types = c("integer", "numeric", "factor", "logical"), - predict_types = c("distr", "crank"), + predict_types = c("crank", "distr"), param_set = ps, man = "mlr3extralearners::mlr_learners_surv.penalized", label = "Penalized Regression" ) + }, + + #' @description + #' Selected features are extracted with the method `coef()` of the S4 model + #' object, see [penalized::penfit()]. + #' By default it returns features with non-zero coefficients. + #' + #' **Note**: Selected features can be retrieved only for datasets with + #' `numeric` features, as the presence of factors with multiple levels makes + #' it difficult to get the original feature names. + #' + #' @return `character()`. + selected_features = function() { + if (is.null(self$model$model)) { + stopf("No model stored") + } + + if (self$model$task_has_factors) { + stopf("Can't return selected features as trained task had factor variables + and original feature names cannot be retrieved") + } + + # Per default, only coefficients of selected variables are returned by coef() + names(penalized::coef(self$model$model)) } ), private = list( .train = function(task) { - - # Checks missing data early to prevent crashing, which is not caught earlier by task/train - - if (any(task$missings() > 0)) { - stop("Missing data is not supported by ", self$id) - } - - # Changes the structure of the penalized and unpenalized parameters to be more user friendly. - # Now the user supplies the column names as a vector and these are added to the formula as - # required. pars = self$param_set$get_values(tags = "train") if (length(pars$unpenalized) == 0) { + # if no "unpenalized" features, penalize all (no need to set `pars$unpenalized`) penalized = formulate(rhs = task$feature_names) } else { - if (any(pars$penalized %nin% task$feature_names)) { - stopf("Parameter 'penalized' contains values not present in task") + if (any(pars$unpenalized %nin% task$feature_names)) { + stopf("Parameter 'unpenalized' contains values not present in task") } + # if some "unpenalized" features exist, penalize the rest penalized = formulate(rhs = task$feature_names[task$feature_names %nin% pars$unpenalized]) pars$unpenalized = formulate(rhs = pars$unpenalized) } @@ -83,19 +113,23 @@ LearnerSurvPenalized = R6Class("LearnerSurvPenalized", # also there is a bug in withr, which does not clean up Depends, therefore # we need the double with_package # https://github.com/r-lib/withr/issues/261 - with_package("survival", { + model = with_package("survival", { with_package("penalized", { invoke(penalized::penalized, response = task$truth(), penalized = penalized, data = task$data(cols = task$feature_names), model = "cox", .args = pars) }) }) + + list( + model = model, + task_has_factors = any(task$feature_types$type == "factor") + ) }, .predict = function(task) { # Again the penalized and unpenalized covariates are automatically converted to the # correct formula - pars = self$param_set$get_values(tags = "predict") if (length(pars$unpenalized) == 0) { penalized = formulate(rhs = task$feature_names) @@ -105,10 +139,11 @@ LearnerSurvPenalized = R6Class("LearnerSurvPenalized", } surv = with_package("penalized", { - invoke(penalized::predict, self$model, - penalized = penalized, - data = ordered_features(task, self), - .args = pars) + invoke(penalized::predict, + self$model$model, + penalized = penalized, + data = ordered_features(task, self), + .args = pars) }) mlr3proba::.surv_return(times = surv@time, surv = surv@curves) diff --git a/R/learner_prioritylasso_classif_priority_lasso.R b/R/learner_prioritylasso_classif_priority_lasso.R index 2374e9bef..74719b999 100644 --- a/R/learner_prioritylasso_classif_priority_lasso.R +++ b/R/learner_prioritylasso_classif_priority_lasso.R @@ -6,6 +6,9 @@ #' Patient outcome prediction based on multi-omics data taking practitioners’ preferences into account. #' Calls [prioritylasso::prioritylasso()] from \CRANpkg{prioritylasso}. #' +#' @section Initial parameter values: +#' - `family` is set to `"binomial"` and canno be changed +#' #' @templateVar id classif.priority_lasso #' @template learner #' @@ -104,7 +107,7 @@ LearnerClassifPriorityLasso = R6Class("LearnerClassifPriorityLasso", }, #' @description - #' Selected features, i.e. those where the coefficient is positive. + #' Selected features, i.e. those where the coefficient is non-zero. #' @return `character()`. selected_features = function() { if (is.null(self$model)) { diff --git a/R/learner_prioritylasso_regr_priority_lasso.R b/R/learner_prioritylasso_regr_priority_lasso.R index 7a48fbcdd..077a67bb6 100644 --- a/R/learner_prioritylasso_regr_priority_lasso.R +++ b/R/learner_prioritylasso_regr_priority_lasso.R @@ -6,6 +6,9 @@ #' Patient outcome prediction based on multi-omics data taking practitioners’ preferences into account. #' Calls [prioritylasso::prioritylasso()] from \CRANpkg{prioritylasso}. #' +#' @section Initial parameter values: +#' - `family` is set to `"gaussian"` and cannot be changed +#' - `type.measure` set to `"mse"` (cross-validation measure) #' #' @templateVar id regr.priority_lasso #' @template learner diff --git a/R/learner_prioritylasso_surv_priority_lasso.R b/R/learner_prioritylasso_surv_priority_lasso.R index 9e3cec673..6bcae68e6 100644 --- a/R/learner_prioritylasso_surv_priority_lasso.R +++ b/R/learner_prioritylasso_surv_priority_lasso.R @@ -5,6 +5,25 @@ #' @description #' Patient outcome prediction based on multi-omics data taking practitioners’ preferences into account. #' Calls [prioritylasso::prioritylasso()] from \CRANpkg{prioritylasso}. +#' Many parameters for this survival learner are the same as [mlr_learners_surv.cv_glmnet] +#' as `prioritylasso()` calls [glmnet::cv.glmnet()] during training phase. +#' Note that `prioritylasso()` has ways to deal with block-wise missing data, +#' but this feature is not supported currently. +#' +#' @section Prediction types: +#' This learner returns three prediction types: +#' 1. `lp`: a vector containing the linear predictors (relative risk scores), +#' where each score corresponds to a specific test observation. +#' Calculated using [prioritylasso::predict.prioritylasso()]. +#' 2. `crank`: same as `lp`. +#' 3. `distr`: a survival matrix in two dimensions, where observations are +#' represented in rows and time points in columns. +#' Calculated using [mlr3proba::breslow()] where the Breslow estimator is used +#' for computing the baseline hazard. +#' +#' @section Initial parameter values: +#' - `family` is set to `"cox"` for the Cox survival objective and cannot be changed +#' - `type.measure` set to `"deviance"` (cross-validation measure) #' #' @templateVar id surv.priority_lasso #' @template learner @@ -13,7 +32,27 @@ #' `r format_bib("klau2018priolasso")` #' #' @template seealso_learner -#' @template simple_example +#' @examplesIf mlr3misc::require_namespaces(c("mlr3proba"), quietly = TRUE) +#' # Define a Task +#' task = tsk("grace") +#' # Create train and test set +#' ids = partition(task) +#' # check task's features +#' task$feature_names +#' # partition features to 2 blocks +#' blocks = list(bl1 = 1:3, bl2 = 4:6) +#' # define learner +#' learner = lrn("surv.priority_lasso", blocks = blocks, block1.penalization = FALSE, +#' lambda.type = "lambda.1se", standardize = TRUE, nfolds = 5) +#' # Train the learner on the training ids +#' learner$train(task, row_ids = ids$train) +#' # selected features +#' learner$selected_features() +#' # Make predictions for the test observations +#' pred = learner$predict(task, row_ids = ids$test) +#' pred +#' # Score the predictions +#' pred$score() #' @export LearnerSurvPriorityLasso = R6Class("LearnerSurvPriorityLasso", inherit = mlr3proba::LearnerSurv, @@ -22,21 +61,20 @@ LearnerSurvPriorityLasso = R6Class("LearnerSurvPriorityLasso", #' Creates a new instance of this [R6][R6::R6Class] class. initialize = function() { param_set = ps( - blocks = p_uty(tags = c("train", "required")), - max.coef = p_uty(default = NULL, tags = "train"), - block1.penalization = p_lgl(default = TRUE, tags = "train"), - lambda.type = p_fct(default = "lambda.min", levels = c("lambda.min", "lambda.1se"), tags = c("train", "predict")), #nolint - standardize = p_lgl(default = TRUE, tags = "train"), - nfolds = p_int(default = 5L, lower = 1L, tags = "train"), - foldid = p_uty(default = NULL, tags = "train"), - cvoffset = p_lgl(default = FALSE, tags = "train"), - cvoffsetnfolds = p_int(default = 10, lower = 1L, tags = "train"), - return.x = p_lgl(default = TRUE, tags = "train"), - handle.missingtestdata = p_fct(c("none", "omit.prediction", "set.zero", "impute.block"), tags = "predict"), - include.allintercepts = p_lgl(default = FALSE, tags = "predict"), - use.blocks = p_uty(default = "all", tags = "predict"), + blocks = p_uty(tags = c("train", "required")), + max.coef = p_uty(default = NULL, tags = "train"), + block1.penalization = p_lgl(default = TRUE, tags = "train"), + lambda.type = p_fct(default = "lambda.min", levels = c("lambda.min", "lambda.1se"), tags = "train"), + standardize = p_lgl(default = TRUE, tags = "train"), + nfolds = p_int(default = 5L, lower = 1L, tags = "train"), + foldid = p_uty(default = NULL, tags = "train"), + cvoffset = p_lgl(default = FALSE, tags = "train"), + cvoffsetnfolds = p_int(default = 10, lower = 1L, tags = "train"), + return.x = p_lgl(default = TRUE, tags = "train"), + include.allintercepts = p_lgl(default = FALSE, tags = "predict"), + use.blocks = p_uty(default = "all", tags = "predict"), - # params from cv.glmnet + # params from cv.glmnet, passed to `prioritylasso()` during `.train()` alignment = p_fct(c("lambda", "fraction"), default = "lambda", tags = "train"), alpha = p_dbl(0, 1, default = 1, tags = "train"), big = p_dbl(default = 9.9e35, tags = "train"), @@ -72,16 +110,14 @@ LearnerSurvPriorityLasso = R6Class("LearnerSurvPriorityLasso", type.logistic = p_fct(c("Newton", "modified.Newton"), default = "Newton", tags = "train"), type.multinomial = p_fct(c("ungrouped", "grouped"), default = "ungrouped", tags = "train"), upper.limits = p_uty(default = Inf, tags = "train"), - predict.gamma = p_dbl(default = "gamma.1se", special_vals = list("gamma.1se", "gamma.min"), tags = "predict"), #nolint - relax = p_lgl(default = FALSE, tags = "train"), - s = p_dbl(0, 1, special_vals = list("lambda.1se", "lambda.min"), default = "lambda.1se", tags = "predict") #nolint + relax = p_lgl(default = FALSE, tags = "train") ) super$initialize( id = "surv.priority_lasso", packages = "prioritylasso", feature_types = c("logical", "integer", "numeric"), - predict_types = c("response", "lp"), + predict_types = c("crank", "lp", "distr"), param_set = param_set, properties = c("weights", "selected_features"), man = "mlr3extralearners::mlr_learners_surv.priority_lasso", @@ -90,7 +126,7 @@ LearnerSurvPriorityLasso = R6Class("LearnerSurvPriorityLasso", }, #' @description - #' Selected features, i.e. those where the coefficient is positive. + #' Selected features, i.e. those where the coefficient is non-zero. #' @return `character()`. selected_features = function() { if (is.null(self$model)) { @@ -113,31 +149,41 @@ LearnerSurvPriorityLasso = R6Class("LearnerSurvPriorityLasso", } data = as.matrix(task$data(cols = task$feature_names)) target = task$truth() - invoke(prioritylasso::prioritylasso, - X = data, Y = target, - .args = pars) + + model = invoke(prioritylasso::prioritylasso, X = data, Y = target, .args = pars) + # add (time, status) of training data for breslow distr prediction + model$train_times = task$times() + model$train_status = task$status() + + model }, - .predict = function(task) { - # get parameters with tag "predict" - pars = self$param_set$get_values(tags = "predict") - pars = rename(pars, "predict.gamma", "gamma") + .predict = function(task) { # get newdata and ensure same ordering in train and predict newdata = as.matrix(ordered_features(task, self)) - # Calculate predictions for the selected predict type. - type = self$predict_type - if (type == "lp") { - type = "link" - } + # get parameters with tag "predict" + pv = self$param_set$get_values(tags = "predict") - pred = invoke(predict, self$model, newdata = newdata, type = type, .args = pars) + # get linear predictor for train data + lp_train = as.numeric( + invoke(predict, self$model, type = "link", .args = pv) + ) - if (type == "response") { - list(response = pred, crank = pred) - } else { - list(lp = pred, crank = pred) - } + # get linear predictor for test data + lp_test = as.numeric( + invoke(predict, self$model, newdata = newdata, type = "link", .args = pv) + ) + + # get survival probability matrix using the Breslow estimator for the baseline hazard + surv = mlr3proba::breslow( + times = self$model$train_times, + status = self$model$train_status, + lp_train = lp_train, + lp_test = lp_test + ) + + mlr3proba::.surv_return(surv = surv, lp = lp_test) } ) ) diff --git a/R/learner_randomForestSRC_classif_imbalanced_rfsrc.R b/R/learner_randomForestSRC_classif_imbalanced_rfsrc.R index 5a1ca3c1d..b47b0eb06 100644 --- a/R/learner_randomForestSRC_classif_imbalanced_rfsrc.R +++ b/R/learner_randomForestSRC_classif_imbalanced_rfsrc.R @@ -16,7 +16,28 @@ #' `r format_bib("obrien2019imbrfsrc", "chen2004imbrf")` #' #' @template seealso_learner -#' @template example +#' @examplesIf requireNamespace("randomForestSRC", quietly = TRUE) +#' # Define the Learner +#' learner = mlr3::lrn("classif.imbalanced_rfsrc", importance = "TRUE") +#' print(learner) +#' +#' # Define a Task +#' task = mlr3::tsk("sonar") +#' # Create train and test set +#' ids = mlr3::partition(task) +#' +#' # Train the learner on the training ids +#' learner$train(task, row_ids = ids$train) +#' +#' print(learner$model) +#' print(learner$importance()) +#' +#' # Make predictions for the test rows +#' predictions = learner$predict(task, row_ids = ids$test) +#' +#' # Score the predictions +#' predictions$score() +#' #' @export LearnerClassifImbalancedRandomForestSRC = R6Class("LearnerClassifImbalancedRandomForestSRC", inherit = LearnerClassif, @@ -25,7 +46,7 @@ LearnerClassifImbalancedRandomForestSRC = R6Class("LearnerClassifImbalancedRando #' Creates a new instance of this [R6][R6::R6Class] class. initialize = function() { ps = ps( - ntree = p_int(default = 3000, lower = 1L, tags = "train"), + ntree = p_int(default = 500L, lower = 1L, tags = "train"), method = p_fct( default = "rfq", levels = c("rfq", "brf", "standard"), diff --git a/R/learner_randomForestSRC_classif_rfsrc.R b/R/learner_randomForestSRC_classif_rfsrc.R index 4c5b92089..e7d1463e9 100644 --- a/R/learner_randomForestSRC_classif_rfsrc.R +++ b/R/learner_randomForestSRC_classif_rfsrc.R @@ -10,22 +10,40 @@ #' @templateVar id classif.rfsrc #' #' @section Custom mlr3 parameters: -#' - `mtry`: -#' - This hyperparameter can alternatively be set via the added hyperparameter `mtry.ratio` -#' as `mtry = max(ceiling(mtry.ratio * n_features), 1)`. -#' Note that `mtry` and `mtry.ratio` are mutually exclusive. -#' - `sampsize`: -#' - This hyperparameter can alternatively be set via the added hyperparameter `sampsize.ratio` -#' as `sampsize = max(ceiling(sampsize.ratio * n_obs), 1)`. -#' Note that `sampsize` and `sampsize.ratio` are mutually exclusive. -#' - `cores`: -#' This value is set as the option `rf.cores` during training and is set to 1 by default. +#' - `mtry`: This hyperparameter can alternatively be set via the added +#' hyperparameter `mtry.ratio` as `mtry = max(ceiling(mtry.ratio * n_features), 1)`. +#' Note that `mtry` and `mtry.ratio` are mutually exclusive. +#' - `sampsize`: This hyperparameter can alternatively be set via the added +#' hyperparameter `sampsize.ratio` as `sampsize = max(ceiling(sampsize.ratio * n_obs), 1)`. +#' Note that `sampsize` and `sampsize.ratio` are mutually exclusive. +#' - `cores`: This value is set as the option `rf.cores` during training and is +#' set to 1 by default. #' #' @references #' `r format_bib("breiman_2001")` #' #' @template seealso_learner -#' @template example +#' @examplesIf requireNamespace("randomForestSRC", quietly = TRUE) +#' # Define the Learner +#' learner = mlr3::lrn("classif.rfsrc", importance = "TRUE") +#' print(learner) +#' +#' # Define a Task +#' task = mlr3::tsk("sonar") +#' # Create train and test set +#' ids = mlr3::partition(task) +#' +#' # Train the learner on the training ids +#' learner$train(task, row_ids = ids$train) +#' +#' print(learner$model) +#' print(learner$importance()) +#' +#' # Make predictions for the test rows +#' predictions = learner$predict(task, row_ids = ids$test) +#' +#' # Score the predictions +#' predictions$score() #' @export LearnerClassifRandomForestSRC = R6Class("LearnerClassifRandomForestSRC", inherit = LearnerClassif, @@ -35,7 +53,7 @@ LearnerClassifRandomForestSRC = R6Class("LearnerClassifRandomForestSRC", #' Creates a new instance of this [R6][R6::R6Class] class. initialize = function() { ps = ps( - ntree = p_int(default = 1000, lower = 1L, tags = "train"), + ntree = p_int(default = 500L, lower = 1L, tags = "train"), mtry = p_int(lower = 1L, tags = "train"), mtry.ratio = p_dbl(lower = 0, upper = 1, tags = "train"), nodesize = p_int(default = 15L, lower = 1L, tags = "train"), diff --git a/R/learner_randomForestSRC_regr_rfsrc.R b/R/learner_randomForestSRC_regr_rfsrc.R index 5727883b8..381223c75 100644 --- a/R/learner_randomForestSRC_regr_rfsrc.R +++ b/R/learner_randomForestSRC_regr_rfsrc.R @@ -15,7 +15,27 @@ #' `r format_bib("breiman_2001")` #' #' @template seealso_learner -#' @template example +#' @examplesIf requireNamespace("randomForestSRC", quietly = TRUE) +#' # Define the Learner +#' learner = mlr3::lrn("regr.rfsrc", importance = "TRUE") +#' print(learner) +#' +#' # Define a Task +#' task = mlr3::tsk("mtcars") +#' # Create train and test set +#' ids = mlr3::partition(task) +#' +#' # Train the learner on the training ids +#' learner$train(task, row_ids = ids$train) +#' +#' print(learner$model) +#' print(learner$importance()) +#' +#' # Make predictions for the test rows +#' predictions = learner$predict(task, row_ids = ids$test) +#' +#' # Score the predictions +#' predictions$score() #' @export LearnerRegrRandomForestSRC = R6Class("LearnerRegrRandomForestSRC", inherit = LearnerRegr, @@ -25,7 +45,7 @@ LearnerRegrRandomForestSRC = R6Class("LearnerRegrRandomForestSRC", #' Creates a new instance of this [R6][R6::R6Class] class. initialize = function() { ps = ps( - ntree = p_int(default = 1000, lower = 1L, tags = "train"), + ntree = p_int(default = 500L, lower = 1L, tags = "train"), mtry = p_int(lower = 1L, tags = "train"), mtry.ratio = p_dbl(lower = 0, upper = 1, tags = "train"), nodesize = p_int(default = 15L, lower = 1L, tags = "train"), diff --git a/R/learner_randomForestSRC_surv_rfsrc.R b/R/learner_randomForestSRC_surv_rfsrc.R index b431ad29a..bc52e7c2d 100644 --- a/R/learner_randomForestSRC_surv_rfsrc.R +++ b/R/learner_randomForestSRC_surv_rfsrc.R @@ -6,23 +6,58 @@ #' Random survival forest. #' Calls [randomForestSRC::rfsrc()] from \CRANpkg{randomForestSRC}. #' +#' @section Prediction types: +#' This learner returns two prediction types: +#' 1. `distr`: a survival matrix in two dimensions, where observations are +#' represented in rows and (unique event) time points in columns. +#' Calculated using the internal [randomForestSRC::predict.rfsrc()] function. +#' 2. `crank`: the expected mortality using [mlr3proba::.surv_return()]. +#' #' @template learner #' @templateVar id surv.rfsrc #' #' @inheritSection mlr_learners_classif.rfsrc Custom mlr3 parameters #' -#' @details -#' [randomForestSRC::predict.rfsrc()] returns both cumulative hazard function (chf) and -#' survival function (surv) but uses different estimators to derive these. `chf` uses a -#' bootstrapped Nelson-Aalen estimator, (Ishwaran, 2008) whereas `surv` uses a bootstrapped -#' Kaplan-Meier estimator. The choice of which estimator to use is given by the extra -#' `estimator` hyper-parameter, default is `nelson`. +#' @section Custom mlr3 parameters: +#' - `estimator`: Hidden parameter that controls the type of estimator used to +#' derive the survival function during prediction. The **default** value is `"chf"` which +#' uses a bootstrapped Nelson-Aalen estimator for the cumulative hazard function +#' \eqn{H(t)}, (Ishwaran, 2008) from which we calculate \eqn{S(t) = \exp(-H(t))}, +#' whereas `"surv"` uses a bootstrapped Kaplan-Meier estimator to directly estimate +#' \eqn{S(t)}. +#' +#' @section Initial parameter values: +#' - `ntime`: Number of time points to coerce the observed event times for use in the +#' estimated survival function during prediction. We changed the default value +#' of `150` to `0` in order to be in line with other random survival forest +#' learners and use all the **unique event times from the train set**. #' #' @references #' `r format_bib("ishwaran_2008", "breiman_2001")` #' #' @template seealso_learner -#' @template example +#' @examplesIf requireNamespace("randomForestSRC", quietly = TRUE) +#' # Define the Learner +#' learner = mlr3::lrn("surv.rfsrc", importance = "TRUE") +#' print(learner) +#' +#' # Define a Task +#' task = mlr3::tsk("grace") +#' +#' # Create train and test set +#' ids = mlr3::partition(task) +#' +#' # Train the learner on the training ids +#' learner$train(task, row_ids = ids$train) +#' +#' print(learner$model) +#' print(learner$importance()) +#' +#' # Make predictions for the test rows +#' predictions = learner$predict(task, row_ids = ids$test) +#' +#' # Score the predictions +#' predictions$score() #' @export LearnerSurvRandomForestSRC = R6Class("LearnerSurvRandomForestSRC", inherit = mlr3proba::LearnerSurv, @@ -32,7 +67,7 @@ LearnerSurvRandomForestSRC = R6Class("LearnerSurvRandomForestSRC", #' Creates a new instance of this [R6][R6::R6Class] class. initialize = function() { ps = ps( - ntree = p_int(default = 1000, lower = 1L, tags = "train"), + ntree = p_int(default = 500L, lower = 1L, tags = "train"), mtry = p_int(lower = 1L, tags = "train"), mtry.ratio = p_dbl(lower = 0, upper = 1, tags = "train"), nodesize = p_int(default = 15L, lower = 1L, tags = "train"), @@ -59,8 +94,8 @@ LearnerSurvRandomForestSRC = R6Class("LearnerSurvRandomForestSRC", na.action = p_fct( default = "na.omit", levels = c("na.omit", "na.impute"), tags = c("train", "predict")), - nimpute = p_int(default = 1L, lower = 1L, tags = "train"), - ntime = p_int(lower = 1L, tags = "train"), + nimpute = p_int(lower = 1L, default = 1L, special_vals = list(NULL), tags = "train"), + ntime = p_int(lower = 0L, default = 150L, special_vals = list(NULL), tags = "train"), cause = p_int(lower = 1L, tags = "train"), proximity = p_fct( default = "FALSE", @@ -99,6 +134,8 @@ LearnerSurvRandomForestSRC = R6Class("LearnerSurvRandomForestSRC", case.depth = p_lgl(default = FALSE, tags = c("train", "predict")) ) + ps$values$ntime = 0 + super$initialize( id = "surv.rfsrc", packages = c("mlr3extralearners", "randomForestSRC", "pracma"), @@ -171,13 +208,11 @@ LearnerSurvRandomForestSRC = R6Class("LearnerSurvRandomForestSRC", pars_predict$cores = NULL p = invoke(predict, object = self$model, newdata = newdata, .args = pars_predict, - .opts = list(rf.cores = cores)) + .opts = list(rf.cores = cores)) # rfsrc uses Nelson-Aalen in chf and Kaplan-Meier for survival, as these # don't give equivalent results one must be chosen and the relevant functions are transformed # as required. - - surv = if (estimator == "nelson") exp(-p$chf) else p$survival mlr3proba::.surv_return(times = self$model$time.interest, surv = surv) diff --git a/R/learner_randomForest_classif_randomForest.R b/R/learner_randomForest_classif_randomForest.R index 412575770..8bb7914e7 100644 --- a/R/learner_randomForest_classif_randomForest.R +++ b/R/learner_randomForest_classif_randomForest.R @@ -12,9 +12,29 @@ #' @references #' `r format_bib("breiman_2001")` #' -#' @export #' @template seealso_learner -#' @template example +#' @examplesIf requireNamespace("randomForest", quietly = TRUE) +#' # Define the Learner +#' learner = mlr3::lrn("classif.randomForest", importance = "accuracy") +#' print(learner) +#' +#' # Define a Task +#' task = mlr3::tsk("sonar") +#' # Create train and test set +#' ids = mlr3::partition(task) +#' +#' # Train the learner on the training ids +#' learner$train(task, row_ids = ids$train) +#' +#' print(learner$model) +#' print(learner$importance()) +#' +#' # Make predictions for the test rows +#' predictions = learner$predict(task, row_ids = ids$test) +#' +#' # Score the predictions +#' predictions$score() +#' @export LearnerClassifRandomForest = R6Class("LearnerClassifRandomForest", inherit = LearnerClassif, diff --git a/R/learner_randomForest_regr_randomForest.R b/R/learner_randomForest_regr_randomForest.R index d6fa2455e..7674217be 100644 --- a/R/learner_randomForest_regr_randomForest.R +++ b/R/learner_randomForest_regr_randomForest.R @@ -12,9 +12,29 @@ #' @references #' `r format_bib("breiman_2001")` #' -#' @export #' @template seealso_learner -#' @template example +#' @examplesIf requireNamespace("randomForest", quietly = TRUE) +#' # Define the Learner +#' learner = mlr3::lrn("regr.randomForest", importance = "mse") +#' print(learner) +#' +#' # Define a Task +#' task = mlr3::tsk("mtcars") +#' # Create train and test set +#' ids = mlr3::partition(task) +#' +#' # Train the learner on the training ids +#' learner$train(task, row_ids = ids$train) +#' +#' print(learner$model) +#' print(learner$importance()) +#' +#' # Make predictions for the test rows +#' predictions = learner$predict(task, row_ids = ids$test) +#' +#' # Score the predictions +#' predictions$score() +#' @export LearnerRegrRandomForest = R6Class("LearnerRegrRandomForest", inherit = LearnerRegr, diff --git a/R/learner_ranger_surv_ranger.R b/R/learner_ranger_surv_ranger.R index 7827caa1b..3e0a2afbe 100644 --- a/R/learner_ranger_surv_ranger.R +++ b/R/learner_ranger_surv_ranger.R @@ -6,11 +6,17 @@ #' Random survival forest. #' Calls [ranger::ranger()] from package \CRANpkg{ranger}. #' +#' @section Prediction types: +#' This learner returns two prediction types: +#' 1. `distr`: a survival matrix in two dimensions, where observations are +#' represented in rows and (unique event) time points in columns. +#' Calculated using the internal [ranger::predict.ranger()] function. +#' 2. `crank`: the expected mortality using [mlr3proba::.surv_return()]. +#' #' @section Custom mlr3 parameters: -#' - `mtry`: -#' - This hyperparameter can alternatively be set via our hyperparameter `mtry.ratio` -#' as `mtry = max(ceiling(mtry.ratio * n_features), 1)`. -#' Note that `mtry` and `mtry.ratio` are mutually exclusive. +#' - `mtry`: This hyperparameter can alternatively be set via our hyperparameter +#' `mtry.ratio` as `mtry = max(ceiling(mtry.ratio * n_features), 1)`. +#' Note that `mtry` and `mtry.ratio` are mutually exclusive. #' #' @section Initial parameter values: #' - `num.threads` is initialized to 1 to avoid conflicts with parallelization via \CRANpkg{future}. @@ -21,9 +27,30 @@ #' @references #' `r format_bib("wright_2017", "breiman_2001")` #' -#' @export #' @template seealso_learner -#' @template example +#' @examplesIf requireNamespace("ranger", quietly = TRUE) +#' # Define the Learner +#' learner = mlr3::lrn("surv.ranger", importance = "permutation") +#' print(learner) +#' +#' # Define a Task +#' task = mlr3::tsk("grace") +#' +#' # Create train and test set +#' ids = mlr3::partition(task) +#' +#' # Train the learner on the training ids +#' learner$train(task, row_ids = ids$train) +#' +#' print(learner$model) +#' print(learner$importance()) +#' +#' # Make predictions for the test rows +#' predictions = learner$predict(task, row_ids = ids$test) +#' +#' # Score the predictions +#' predictions$score() +#' @export LearnerSurvRanger = R6Class("LearnerSurvRanger", inherit = mlr3proba::LearnerSurv, public = list( @@ -67,7 +94,7 @@ LearnerSurvRanger = R6Class("LearnerSurvRanger", super$initialize( id = "surv.ranger", param_set = ps, - predict_types = c("distr", "crank"), + predict_types = c("crank", "distr"), feature_types = c("logical", "integer", "numeric", "character", "factor", "ordered"), properties = c("weights", "importance", "oob_error"), packages = c("mlr3extralearners", "ranger"), diff --git a/R/learner_survival_surv_nelson.R b/R/learner_survival_surv_nelson.R index b433b94ec..82b47bc3d 100644 --- a/R/learner_survival_surv_nelson.R +++ b/R/learner_survival_surv_nelson.R @@ -4,7 +4,17 @@ #' #' @description #' Non-parametric estimator of the cumulative hazard rate function. -#' Calls [survival::survfit()] from \CRANpkg{survival}. +#' Calls [survival::survfit()] from \CRANpkg{survival}. +#' +#' @section Prediction types: +#' This learner returns two prediction types: +#' 1. `distr`: a survival matrix in two dimensions, where observations are +#' represented in rows and time points in columns. +#' The cumulative hazard \eqn{H(t)} is calculated using the train data and the +#' default parameters of the [survival::survfit()] function, i.e. `ctype = 1`, +#' which uses the Nelson-Aalen formula. +#' Then for each test observation the survival curve is \eqn{S(t) = \exp{(-H(t))}}. +#' 2. `crank`: the expected mortality using [mlr3proba::.surv_return()]. #' #' @template learner #' @templateVar id surv.nelson diff --git a/R/learner_survivalmodels_surv_akritas.R b/R/learner_survivalmodels_surv_akritas.R index 20b391ed8..846ae7873 100644 --- a/R/learner_survivalmodels_surv_akritas.R +++ b/R/learner_survivalmodels_surv_akritas.R @@ -6,6 +6,17 @@ #' Survival akritas estimator. #' Calls [survivalmodels::akritas()] from package 'survivalmodels'. #' +#' @section Prediction types: +#' This learner returns two prediction types: +#' 1. `distr`: a survival matrix in two dimensions, where observations are +#' represented in rows and time points in columns. +#' Calculated using the internal [survivalmodels::predict.akritas()] function. +#' The survival matrix uses the unique time points from the training set. +#' We advise to set the parameter `ntime` which allows to adjust the granularity +#' of these time points to a reasonable number (e.g. `150`). +#' This avoids large execution times during prediction. +#' 2. `crank`: the expected mortality using [survivalmodels::surv_to_risk()]. +#' #' @template learner #' @templateVar id surv.akritas #' @@ -27,7 +38,7 @@ LearnerSurvAkritas = R6Class("LearnerSurvAkritas", ps = ps( lambda = p_dbl(default = 0.5, lower = 0, upper = 1, tags = "predict"), reverse = p_lgl(default = FALSE, tags = "train"), - ntime = p_dbl(default = 150, lower = 1, tags = "predict"), + ntime = p_int(lower = 1, default = NULL, special_vals = list(NULL), tags = "predict"), round_time = p_int(default = 2, lower = 0, special_vals = list(FALSE), tags = "predict") ) @@ -45,27 +56,33 @@ LearnerSurvAkritas = R6Class("LearnerSurvAkritas", private = list( .train = function(task) { - pars = self$param_set$get_values(tags = "train") + pv = self$param_set$get_values(tags = "train") invoke( survivalmodels::akritas, data = data.table::setDF(task$data()), time_variable = task$target_names[1L], status_variable = task$target_names[2L], - .args = pars + .args = pv ) }, .predict = function(task) { - pars = self$param_set$get_values(tags = "predict") + pv = self$param_set$get_values(tags = "predict") newdata = ordered_features(task, self) + # use train set times + times = self$model$y[, "time"] + # coerce times points to an `ntime` grid + times = gridify_times(times, pv$ntime) + pred = invoke( predict, self$model, newdata = newdata, + times = times, distr6 = FALSE, type = "all", - .args = pars + .args = pv ) list(crank = pred$risk, distr = pred$surv) diff --git a/R/learner_survivalmodels_surv_coxtime.R b/R/learner_survivalmodels_surv_coxtime.R index 069da6a67..5fb7a0fad 100644 --- a/R/learner_survivalmodels_surv_coxtime.R +++ b/R/learner_survivalmodels_surv_coxtime.R @@ -6,6 +6,13 @@ #' Cox-Time survival model. #' Calls [survivalmodels::coxtime()] from package 'survivalmodels'. #' +#' @section Prediction types: +#' This learner returns two prediction types: +#' 1. `distr`: a survival matrix in two dimensions, where observations are +#' represented in rows and time points in columns. +#' Calculated using the internal [survivalmodels::predict.pycox()] function. +#' 2. `crank`: the expected mortality using [survivalmodels::surv_to_risk()]. +#' #' @template learner #' @templateVar id surv.coxtime #' diff --git a/R/learner_survivalmodels_surv_deephit.R b/R/learner_survivalmodels_surv_deephit.R index 61d3c8df9..e03efabfa 100644 --- a/R/learner_survivalmodels_surv_deephit.R +++ b/R/learner_survivalmodels_surv_deephit.R @@ -6,6 +6,13 @@ #' Neural network 'Deephit' for survival analysis. #' Calls [survivalmodels::deephit()] from pacakge 'survivalmodels'. #' +#' @section Prediction types: +#' This learner returns two prediction types: +#' 1. `distr`: a survival matrix in two dimensions, where observations are +#' represented in rows and time points in columns. +#' Calculated using the internal [survivalmodels::predict.pycox()] function. +#' 2. `crank`: the expected mortality using [survivalmodels::surv_to_risk()]. +#' #' @template learner #' @templateVar id surv.deephit #' diff --git a/R/learner_survivalmodels_surv_deepsurv.R b/R/learner_survivalmodels_surv_deepsurv.R index cbabdccf0..f4e18de97 100644 --- a/R/learner_survivalmodels_surv_deepsurv.R +++ b/R/learner_survivalmodels_surv_deepsurv.R @@ -4,7 +4,14 @@ #' #' @description #' DeepSurv fits a neural network based on the partial likelihood from a Cox PH. -#' Calls [survivalmodels::dnnsurv()] from package 'survivalmodels'. +#' Calls [survivalmodels::deepsurv()] from package 'survivalmodels'. +#' +#' @section Prediction types: +#' This learner returns two prediction types: +#' 1. `distr`: a survival matrix in two dimensions, where observations are +#' represented in rows and time points in columns. +#' Calculated using the internal [survivalmodels::predict.pycox()] function. +#' 2. `crank`: the expected mortality using [survivalmodels::surv_to_risk()]. #' #' @template learner #' @templateVar id surv.deepsurv diff --git a/R/learner_survivalmodels_surv_dnnsurv.R b/R/learner_survivalmodels_surv_dnnsurv.R index 289b70644..89be01e08 100644 --- a/R/learner_survivalmodels_surv_dnnsurv.R +++ b/R/learner_survivalmodels_surv_dnnsurv.R @@ -6,6 +6,13 @@ #' Fits a neural network based on pseudo-conditional survival probabilities. #' Calls [survivalmodels::dnnsurv()] from package 'survivalmodels'. #' +#' @section Prediction types: +#' This learner returns two prediction types: +#' 1. `distr`: a survival matrix in two dimensions, where observations are +#' represented in rows and time points in columns. +#' Calculated using the internal [survivalmodels::predict.dnnsurv()] function. +#' 2. `crank`: the expected mortality using [survivalmodels::surv_to_risk()]. +#' #' @template learner #' @templateVar id surv.dnnsurv #' diff --git a/R/learner_survivalmodels_surv_loghaz.R b/R/learner_survivalmodels_surv_loghaz.R index d16fb5596..6f89e7f20 100644 --- a/R/learner_survivalmodels_surv_loghaz.R +++ b/R/learner_survivalmodels_surv_loghaz.R @@ -6,6 +6,13 @@ #' Survival logistic hazard learner. #' Calls [survivalmodels::loghaz()] from package 'survivalmodels'. #' +#' @section Prediction types: +#' This learner returns two prediction types: +#' 1. `distr`: a survival matrix in two dimensions, where observations are +#' represented in rows and time points in columns. +#' Calculated using the internal [survivalmodels::predict.pycox()] function. +#' 2. `crank`: the expected mortality using [survivalmodels::surv_to_risk()]. +#' #' @templateVar id surv.loghaz #' @template learner #' diff --git a/R/learner_survival_surv_parametric.R b/R/learner_survivalmodels_surv_parametric.R similarity index 75% rename from R/learner_survival_surv_parametric.R rename to R/learner_survivalmodels_surv_parametric.R index 5c2d3fad9..7ed85adfb 100644 --- a/R/learner_survival_surv_parametric.R +++ b/R/learner_survivalmodels_surv_parametric.R @@ -4,38 +4,43 @@ #' #' @description #' Parametric survival model. -#' Calls `parametric()]` from 'survivalmodels'. +#' Calls [survivalmodels::parametric()] from package 'survivalmodels'. +#' +#' @section Prediction types: +#' This learner returns three prediction types: +#' 1. `lp`: a vector of linear predictors (relative risk scores), one per test +#' observation. +#' `lp` is predicted using the formula \eqn{lp = X\beta} where \eqn{X} are the +#' variables in the test data set and \eqn{\beta} are the fitted coefficients. +#' 2. `crank`: same as `lp`. +#' 3. `distr`: a survival matrix in two dimensions, where observations are +#' represented in rows and time points in columns. +#' The distribution `distr` is composed using the `lp` predictions and specifying +#' a model form in the `form` hyper-parameter, see Details. +#' The survival matrix uses the unique time points from the training set. +#' The parameter `ntime` allows to adjust the granularity of these time points +#' to any number (e.g. `150`). #' #' @section Custom mlr3 parameters: #' - `discrete` determines the class of the returned survival probability -#' distribution. If `FALSE` (default) continuous probability -#' distributions are returned using [distr6::VectorDistribution], otherwise -#' [distr6::Matdist] (faster to calculate survival measures that require a -#' `distr` prediction type). +#' distribution. If `FALSE`, vectorized continuous probability distributions are +#' returned using [distr6::VectorDistribution], otherwise a [distr6::Matdist] +#' object, which is faster for calculating survival measures that require a `distr` +#' prediction type. Default option is `TRUE`. #' #' @template learner #' @templateVar id surv.parametric #' @template install_survivalmodels #' #' @details -#' This learner allows you to choose a distribution and a model form to compose -#' a predicted survival probability distribution. +#' This learner allows you to choose a **distribution** and a **model form** to compose +#' a predicted survival probability distribution \eqn{S(t)}. #' #' The predict method is implemented in [survivalmodels::predict.parametric()]. #' Our implementation is more efficient for composition to distributions than #' [survival::predict.survreg()]. #' -#' Three types of prediction are returned for this learner: -#' 1. `lp`: a vector of linear predictors (relative risk scores), one per test -#' observation. -#' `lp` is predicted using the formula \eqn{lp = X\beta} where \eqn{X} are the -#' variables in the test data set and \eqn{\beta} are the fitted coefficients. -#' 2. `crank`: same as `lp`. -#' 3. `distr`: a survival matrix in two dimensions, where observations are -#' represented in rows and time points in columns. -#' The distribution `distr` is composed using the `lp` predictions and specifying -#' a model form in the `form` hyper-parameter. These are as follows, with respective -#' survival functions: +#' The available model forms with their respective survival functions, are as follows: #' #' - Accelerated Failure Time (`aft`) \deqn{S(t) = S_0(\frac{t}{exp(lp)})}{S(t) = S0(t/exp(lp))} #' - Proportional Hazards (`ph`) \deqn{S(t) = S_0(t)^{exp(lp)}}{S(t) = S0(t)^exp(lp)} @@ -45,7 +50,7 @@ #' #' where \eqn{S_0}{S0} is the estimated baseline survival distribution (in #' this case with a given parametric form), \eqn{lp} is the predicted linear -#' predictor, \eqn{\Phi} is the cdf of a N(0, 1) distribution, and \eqn{s} is +#' predictor, \eqn{\Phi} is the cdf of a \eqn{N(0, 1)} distribution, and \eqn{s} is #' the fitted scale parameter. #' #' Whilst any combination of distribution and model form is possible, this does @@ -91,15 +96,17 @@ LearnerSurvParametric = R6Class("LearnerSurvParametric", robust = p_lgl(default = FALSE, tags = "train"), score = p_lgl(default = FALSE, tags = "train"), cluster = p_uty(tags = "train"), - discrete = p_lgl(tags = c("required", "predict")) + discrete = p_lgl(tags = c("required", "predict")), + ntime = p_int(lower = 1, default = NULL, special_vals = list(NULL), tags = "predict"), + round_time = p_int(default = 2, lower = 0, special_vals = list(FALSE), tags = "predict") ) - ps$values = list(discrete = FALSE, dist = "weibull", form = "aft") + ps$values = list(discrete = TRUE, dist = "weibull", form = "aft") super$initialize( id = "surv.parametric", param_set = ps, - predict_types = c("crank", "distr", "lp"), + predict_types = c("crank", "lp", "distr"), feature_types = c("logical", "integer", "numeric", "factor"), properties = "weights", packages = c("mlr3extralearners", "survival", "pracma"), @@ -128,13 +135,18 @@ LearnerSurvParametric = R6Class("LearnerSurvParametric", .predict = function(task) { pv = self$param_set$get_values(tags = "predict") - newdata = as.data.frame(ordered_features(task, self)) + # use train set times (`y` is a `Surv` object) + times = as.numeric(self$model$model$y[, 1L]) + # coerce times points to an `ntime` grid + times = gridify_times(times, pv$ntime) + pred = invoke( predict, self$model, newdata = newdata, + times = times, distr6 = !pv$discrete, type = "all", .args = pv diff --git a/R/learner_survivalmodels_surv_pchazard.R b/R/learner_survivalmodels_surv_pchazard.R index 64594f121..677dfdecd 100644 --- a/R/learner_survivalmodels_surv_pchazard.R +++ b/R/learner_survivalmodels_surv_pchazard.R @@ -7,6 +7,13 @@ #' predictions of a discrete hazard function, also known as Nnet-Survival. #' Calls [survivalmodels::pchazard()] from package 'survivalmodels'. #' +#' @section Prediction types: +#' This learner returns two prediction types: +#' 1. `distr`: a survival matrix in two dimensions, where observations are +#' represented in rows and time points in columns. +#' Calculated using the internal [survivalmodels::predict.pycox()] function. +#' 2. `crank`: the expected mortality using [survivalmodels::surv_to_risk()]. +#' #' @template learner #' @templateVar id surv.pchazard #' diff --git a/R/learner_survivalsvm_surv_svm.R b/R/learner_survivalsvm_surv_svm.R index e4c4dcf60..0bb289e82 100644 --- a/R/learner_survivalsvm_surv_svm.R +++ b/R/learner_survivalsvm_surv_svm.R @@ -9,6 +9,13 @@ #' @template learner #' @templateVar id surv.svm #' +#' @section Prediction types: +#' This learner returns up to two prediction types: +#' 1. `crank`: a vector containing the continuous ranking scores, where each score +#' corresponds to a specific test observation. +#' 2. `response`: the survival time of each test observation, equal to `-crank`. +#' This prediction type if only available for `"type"` equal to `regression` or `hybrid`. +#' #' @details #' Four possible SVMs can be implemented, dependent on the `type` parameter. These correspond #' to predicting the survival time via regression (`regression`), predicting a continuous rank @@ -18,6 +25,11 @@ #' #' `makediff3` is recommended when using `type = "hybrid"`. #' +#' @section Custom mlr3 parameters: +#' +#' - `gamma`, `mu` have replaced `gamma.mu` so that it's easier to tune these separately. +#' `mu` is only used when `type = "hybrid"`. +#' #' @references #' `r format_bib("van2011improved", "van2011support", "shivaswamy2007support")` #' @@ -25,7 +37,7 @@ #' @examplesIf mlr3misc::require_namespaces(c("mlr3extralearners", "survivalsvm"), quietly = TRUE) #' set.seed(123) #' # Define the Learner and set parameter values -#' learner = lrn("surv.svm", gamma.mu = 0.1) +#' learner = lrn("surv.svm", gamma = 0.1) #' print(learner) #' #' # Define a Task @@ -61,7 +73,8 @@ LearnerSurvSVM = R6Class("LearnerSurvSVM", diff.meth = p_fct( levels = c("makediff1", "makediff2", "makediff3"), tags = c("train")), - gamma.mu = p_uty(tags = c("train", "required")), + gamma = p_dbl(default = NULL, special_vals = list(NULL), tags = "train"), + mu = p_dbl(default = NULL, special_vals = list(NULL), tags = "train"), opt.meth = p_fct( default = "quadprog", levels = c("quadprog", "ipop"), tags = "train"), @@ -89,37 +102,55 @@ LearnerSurvSVM = R6Class("LearnerSurvSVM", predict_types = c("crank", "response"), param_set = ps, man = "mlr3extralearners::mlr_learners_surv.svm", - label = "Support Vector Machine" + label = "Survival Support Vector Machine" ) } ), private = list( .train = function(task) { + pars = self$param_set$get_values(tags = "train") + + # Regularization parameters are defined separately to be tuned more easily + gamma = pars$gamma + mu = pars$mu + type = pars$type + if (!is.null(type) && type == "hybrid") { + # a vector with two parameters is required when `type` = "hybrid" + gamma.mu = c(gamma, mu) + } else { + gamma.mu = gamma + } + # remove `gamma` and `mu` + pars$gamma = NULL + pars$mu = NULL + with_package("survivalsvm", { invoke(survivalsvm::survivalsvm, formula = task$formula(), data = task$data(), - .args = self$param_set$get_values(tags = "train")) + gamma.mu = gamma.mu, # pass `gamma.mu` separately + .args = pars) }) }, .predict = function(task) { pars = self$param_set$get_values(tags = "predict") - fit = predict(self$model, newdata = ordered_features(task, self), - .args = pars - ) + fit = invoke(predict, + self$model, + newdata = ordered_features(task, self), + .args = pars) crank = as.numeric(fit$predicted) - if (is.null(self$param_set$values$type) || - (self$param_set$values$type %in% c("regression", "hybrid"))) { - # higher survival time = lower risk + type = self$param_set$values$type + if (is.null(type) || (type %in% c("regression", "hybrid"))) { + # ranking is like survival time response = crank } else { response = NULL } - # higher rank = higher risk + # higher continuous ranking = lower survival time list(crank = -crank, response = response) } ) diff --git a/R/learner_xgboost_surv_xgboost_aft.R b/R/learner_xgboost_surv_xgboost_aft.R index da65b1c6b..06eb4b569 100644 --- a/R/learner_xgboost_surv_xgboost_aft.R +++ b/R/learner_xgboost_surv_xgboost_aft.R @@ -8,7 +8,7 @@ #' Calls [xgboost::xgb.train()] from package \CRANpkg{xgboost} with `objective` #' set to `survival:aft` and `eval_metric` to `aft-nloglik`. #' -#' @details +#' @section Prediction types: #' This learner returns three prediction types: #' 1. `response`: the estimated survival time \eqn{T} for each test observation. #' 2. `lp`: a vector of linear predictors (relative risk scores), one per @@ -26,7 +26,6 @@ #' @template section_early_stopping #' @templateVar id surv.xgboost.aft #' @template learner -#' @template section_early_stopping #' #' @references #' `r format_bib("chen_2016", "barnwal2022")` diff --git a/R/learner_xgboost_surv_xgboost_cox.R b/R/learner_xgboost_surv_xgboost_cox.R index 2060b1aac..be6b4f935 100644 --- a/R/learner_xgboost_surv_xgboost_cox.R +++ b/R/learner_xgboost_surv_xgboost_cox.R @@ -8,7 +8,7 @@ #' Calls [xgboost::xgb.train()] from package \CRANpkg{xgboost} with `objective` #' set to `survival:cox` and `eval_metric` to `cox-nloglik`. #' -#' @details +#' @section Prediction types: #' Three types of prediction are returned for this learner: #' 1. `lp`: a vector of linear predictors (relative risk scores), one per #' observation. diff --git a/man-roxygen/example.R b/man-roxygen/example.R index c7869189c..7ab50476b 100644 --- a/man-roxygen/example.R +++ b/man-roxygen/example.R @@ -2,13 +2,13 @@ pkgs = setdiff(mlr3::lrn(id)$packages, c("mlr3", "mlr3learners")) l = lrn(id) task_id = if ("LearnerClassif" %in% class(l)) { - "sonar" +"sonar" } else if ("LearnerRegr" %in% class(l)) { - "mtcars" +"mtcars" } else if ("LearnerSurv" %in% class(l)) { - "grace" +"grace" } else if ("LearnerDens" %in% class(l)) { - "faithful" +"faithful" } %> #' @@ -27,7 +27,7 @@ task_id = if ("LearnerClassif" %in% class(l)) { #' learner$train(task, row_ids = ids$train) #' #' print(learner$model) -#' <%= if("importance" %in% l$properties) "print(learner$importance)" %> +#' <%= if("importance" %in% l$properties) "print(learner$importance())" %> #' #' # Make predictions for the test rows #' predictions = learner$predict(task, row_ids = ids$test) diff --git a/man/mlr_learners_classif.AdaBoostM1.Rd b/man/mlr_learners_classif.AdaBoostM1.Rd index 1fc0f3b11..34ebbbfc2 100644 --- a/man/mlr_learners_classif.AdaBoostM1.Rd +++ b/man/mlr_learners_classif.AdaBoostM1.Rd @@ -6,7 +6,7 @@ \title{Classification AdaBoostM1 Learner} \description{ Adaptive boosting algorithm for classification. -Calls \code{\link[RWeka:AdaBoostM1]{RWeka::AdaBoostM1()}} from \CRANpkg{RWeka}. +Calls \code{\link[RWeka:Weka_classifier_meta]{RWeka::AdaBoostM1()}} from \CRANpkg{RWeka}. } \section{Dictionary}{ @@ -127,6 +127,7 @@ henrifnk
Inherited methods
  • mlr3::Learner$base_learner()
  • +
  • mlr3::Learner$encapsulate()
  • mlr3::Learner$format()
  • mlr3::Learner$help()
  • mlr3::Learner$predict()
  • diff --git a/man/mlr_learners_classif.C50.Rd b/man/mlr_learners_classif.C50.Rd index 0e0a51610..f79ab1877 100644 --- a/man/mlr_learners_classif.C50.Rd +++ b/man/mlr_learners_classif.C50.Rd @@ -6,7 +6,7 @@ \title{Classification C5.0 Learner} \description{ Decision Tree Algorithm. -Calls \code{\link[C50:C5.0.formula]{C50::C5.0.formula()}} from \CRANpkg{C50}. +Calls \code{\link[C50:C5.0]{C50::C5.0.formula()}} from \CRANpkg{C50}. } \section{Dictionary}{ @@ -69,6 +69,7 @@ henrifnk
    Inherited methods
    • mlr3::Learner$base_learner()
    • +
    • mlr3::Learner$encapsulate()
    • mlr3::Learner$format()
    • mlr3::Learner$help()
    • mlr3::Learner$predict()
    • diff --git a/man/mlr_learners_classif.IBk.Rd b/man/mlr_learners_classif.IBk.Rd index 60dc121f6..698f9ee95 100644 --- a/man/mlr_learners_classif.IBk.Rd +++ b/man/mlr_learners_classif.IBk.Rd @@ -6,7 +6,7 @@ \title{Classification IBk Learner} \description{ Instance based algorithm: K-nearest neighbours regression. -Calls \code{\link[RWeka:IBk]{RWeka::IBk()}} from \CRANpkg{RWeka}. +Calls \code{\link[RWeka:Weka_classifier_lazy]{RWeka::IBk()}} from \CRANpkg{RWeka}. } \section{Dictionary}{ @@ -134,6 +134,7 @@ henrifnk
      Inherited methods
      • mlr3::Learner$base_learner()
      • +
      • mlr3::Learner$encapsulate()
      • mlr3::Learner$format()
      • mlr3::Learner$help()
      • mlr3::Learner$predict()
      • diff --git a/man/mlr_learners_classif.J48.Rd b/man/mlr_learners_classif.J48.Rd index b3188241c..4e98dff5b 100644 --- a/man/mlr_learners_classif.J48.Rd +++ b/man/mlr_learners_classif.J48.Rd @@ -6,7 +6,7 @@ \title{Classification J48 Learner} \description{ Decision tree algorithm. -Calls \code{\link[RWeka:IBk]{RWeka::IBk()}} from \CRANpkg{RWeka}. +Calls \code{\link[RWeka:Weka_classifier_lazy]{RWeka::IBk()}} from \CRANpkg{RWeka}. } \section{Dictionary}{ @@ -134,6 +134,7 @@ henrifnk
        Inherited methods
        • mlr3::Learner$base_learner()
        • +
        • mlr3::Learner$encapsulate()
        • mlr3::Learner$format()
        • mlr3::Learner$help()
        • mlr3::Learner$predict()
        • diff --git a/man/mlr_learners_classif.JRip.Rd b/man/mlr_learners_classif.JRip.Rd index 988edbfd2..e9c7e6021 100644 --- a/man/mlr_learners_classif.JRip.Rd +++ b/man/mlr_learners_classif.JRip.Rd @@ -6,7 +6,7 @@ \title{Classification JRip Learner} \description{ Repeated Incremental Pruning to Produce Error Reduction. -Calls \code{\link[RWeka:JRip]{RWeka::JRip()}} from \CRANpkg{RWeka}. +Calls \code{\link[RWeka:Weka_classifier_rules]{RWeka::JRip()}} from \CRANpkg{RWeka}. } \section{Dictionary}{ @@ -129,6 +129,7 @@ henrifnk
          Inherited methods
          • mlr3::Learner$base_learner()
          • +
          • mlr3::Learner$encapsulate()
          • mlr3::Learner$format()
          • mlr3::Learner$help()
          • mlr3::Learner$predict()
          • diff --git a/man/mlr_learners_classif.LMT.Rd b/man/mlr_learners_classif.LMT.Rd index 9e2f60d08..7ba63514f 100644 --- a/man/mlr_learners_classif.LMT.Rd +++ b/man/mlr_learners_classif.LMT.Rd @@ -6,7 +6,7 @@ \title{Classification Logistic Model Trees Learner} \description{ Classification tree with logistic regression models at the leaves. -Calls \code{\link[RWeka:LMT]{RWeka::LMT()}} from \CRANpkg{RWeka}. +Calls \code{\link[RWeka:Weka_classifier_trees]{RWeka::LMT()}} from \CRANpkg{RWeka}. } \section{Dictionary}{ @@ -48,7 +48,7 @@ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{ } } -\section{CUstom mlr3 parameters}{ +\section{Custom mlr3 parameters}{ \itemize{ \item \code{output_debug_info}: @@ -130,6 +130,7 @@ henrifnk
            Inherited methods
            • mlr3::Learner$base_learner()
            • +
            • mlr3::Learner$encapsulate()
            • mlr3::Learner$format()
            • mlr3::Learner$help()
            • mlr3::Learner$predict()
            • diff --git a/man/mlr_learners_classif.OneR.Rd b/man/mlr_learners_classif.OneR.Rd index b3f504803..a33984ab0 100644 --- a/man/mlr_learners_classif.OneR.Rd +++ b/man/mlr_learners_classif.OneR.Rd @@ -6,7 +6,7 @@ \title{Classification OneR Learner} \description{ One Rule classification algorithm that yields an extremely simple model. -Calls \code{\link[RWeka:OneR]{RWeka::OneR()}} from \CRANpkg{RWeka}. +Calls \code{\link[RWeka:Weka_classifier_rules]{RWeka::OneR()}} from \CRANpkg{RWeka}. } \section{Dictionary}{ @@ -122,6 +122,7 @@ henrifnk
              Inherited methods
              • mlr3::Learner$base_learner()
              • +
              • mlr3::Learner$encapsulate()
              • mlr3::Learner$format()
              • mlr3::Learner$help()
              • mlr3::Learner$predict()
              • diff --git a/man/mlr_learners_classif.PART.Rd b/man/mlr_learners_classif.PART.Rd index 806047b23..e0a6ee720 100644 --- a/man/mlr_learners_classif.PART.Rd +++ b/man/mlr_learners_classif.PART.Rd @@ -6,7 +6,7 @@ \title{Classification PART Learner} \description{ Regression partition tree. -Calls \code{\link[RWeka:PART]{RWeka::PART()}} from \CRANpkg{RWeka}. +Calls \code{\link[RWeka:Weka_classifier_rules]{RWeka::PART()}} from \CRANpkg{RWeka}. } \section{Dictionary}{ @@ -129,6 +129,7 @@ henrifnk
                Inherited methods
                • mlr3::Learner$base_learner()
                • +
                • mlr3::Learner$encapsulate()
                • mlr3::Learner$format()
                • mlr3::Learner$help()
                • mlr3::Learner$predict()
                • diff --git a/man/mlr_learners_classif.abess.Rd b/man/mlr_learners_classif.abess.Rd index 1da12ab5f..722cbc3d8 100644 --- a/man/mlr_learners_classif.abess.Rd +++ b/man/mlr_learners_classif.abess.Rd @@ -62,13 +62,7 @@ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{ \itemize{ \item \code{num.threads}: This parameter is initialized to 1 (default is 0) to avoid conflicts with the mlr3 parallelization. -} -} - -\section{Custom mlr3 parameters}{ - -\itemize{ -\item \code{family} - Depending on the task type, if the parameter \code{family} is \code{NULL}, it is set to \code{"binomial"} for binary +\item \code{family}: Depends on the task type, if the parameter \code{family} is \code{NULL}, it is set to \code{"binomial"} for binary classification tasks and to \code{"multinomial"} for multiclass classification problems. } } @@ -127,6 +121,7 @@ abess-team
                  Inherited methods
                  • mlr3::Learner$base_learner()
                  • +
                  • mlr3::Learner$encapsulate()
                  • mlr3::Learner$format()
                  • mlr3::Learner$help()
                  • mlr3::Learner$predict()
                  • diff --git a/man/mlr_learners_classif.bart.Rd b/man/mlr_learners_classif.bart.Rd index 9b236e96a..bafc15e95 100644 --- a/man/mlr_learners_classif.bart.Rd +++ b/man/mlr_learners_classif.bart.Rd @@ -135,6 +135,7 @@ ck37
                    Inherited methods
                    • mlr3::Learner$base_learner()
                    • +
                    • mlr3::Learner$encapsulate()
                    • mlr3::Learner$format()
                    • mlr3::Learner$help()
                    • mlr3::Learner$predict()
                    • diff --git a/man/mlr_learners_classif.bayes_net.Rd b/man/mlr_learners_classif.bayes_net.Rd index 4890d75a1..01b037c96 100644 --- a/man/mlr_learners_classif.bayes_net.Rd +++ b/man/mlr_learners_classif.bayes_net.Rd @@ -6,7 +6,7 @@ \title{Classification Bayes Network Learner} \description{ Bayes Network learning using various search algorithms. -Calls \code{\link[RWeka:make_Weka_classifier]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. +Calls \code{\link[RWeka:Weka_interfaces]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. } \section{Custom mlr3 parameters}{ @@ -146,6 +146,7 @@ damirpolat
                      Inherited methods
                      • mlr3::Learner$base_learner()
                      • +
                      • mlr3::Learner$encapsulate()
                      • mlr3::Learner$format()
                      • mlr3::Learner$help()
                      • mlr3::Learner$predict()
                      • diff --git a/man/mlr_learners_classif.catboost.Rd b/man/mlr_learners_classif.catboost.Rd index b43d16c95..8165c6206 100644 --- a/man/mlr_learners_classif.catboost.Rd +++ b/man/mlr_learners_classif.catboost.Rd @@ -219,6 +219,7 @@ Extracted from \code{model$evaluation_log}}
                        Inherited methods
                        • mlr3::Learner$base_learner()
                        • +
                        • mlr3::Learner$encapsulate()
                        • mlr3::Learner$format()
                        • mlr3::Learner$help()
                        • mlr3::Learner$predict()
                        • diff --git a/man/mlr_learners_classif.cforest.Rd b/man/mlr_learners_classif.cforest.Rd index 11f5ab72a..18c52a1f4 100644 --- a/man/mlr_learners_classif.cforest.Rd +++ b/man/mlr_learners_classif.cforest.Rd @@ -140,6 +140,7 @@ sumny
                          Inherited methods
                          • mlr3::Learner$base_learner()
                          • +
                          • mlr3::Learner$encapsulate()
                          • mlr3::Learner$format()
                          • mlr3::Learner$help()
                          • mlr3::Learner$predict()
                          • diff --git a/man/mlr_learners_classif.ctree.Rd b/man/mlr_learners_classif.ctree.Rd index e8057b908..d2b8095a5 100644 --- a/man/mlr_learners_classif.ctree.Rd +++ b/man/mlr_learners_classif.ctree.Rd @@ -134,6 +134,7 @@ sumny
                            Inherited methods
                            • mlr3::Learner$base_learner()
                            • +
                            • mlr3::Learner$encapsulate()
                            • mlr3::Learner$format()
                            • mlr3::Learner$help()
                            • mlr3::Learner$predict()
                            • diff --git a/man/mlr_learners_classif.decision_stump.Rd b/man/mlr_learners_classif.decision_stump.Rd index 021d9b6a6..4bd13567b 100644 --- a/man/mlr_learners_classif.decision_stump.Rd +++ b/man/mlr_learners_classif.decision_stump.Rd @@ -6,7 +6,7 @@ \title{Classification Decision Stump Learner} \description{ Decision Stump Learner. -Calls \code{\link[RWeka:DecisionStump]{RWeka::DecisionStump()}} from \CRANpkg{RWeka}. +Calls \code{\link[RWeka:Weka_classifier_trees]{RWeka::DecisionStump()}} from \CRANpkg{RWeka}. } \section{Custom mlr3 parameters}{ @@ -116,6 +116,7 @@ damirpolat
                              Inherited methods
                              • mlr3::Learner$base_learner()
                              • +
                              • mlr3::Learner$encapsulate()
                              • mlr3::Learner$format()
                              • mlr3::Learner$help()
                              • mlr3::Learner$predict()
                              • diff --git a/man/mlr_learners_classif.decision_table.Rd b/man/mlr_learners_classif.decision_table.Rd index a56e463dd..d3c6207cd 100644 --- a/man/mlr_learners_classif.decision_table.Rd +++ b/man/mlr_learners_classif.decision_table.Rd @@ -6,7 +6,7 @@ \title{Classification Decision Table Learner} \description{ Simple Decision Table majority classifier. -Calls \code{\link[RWeka:make_Weka_classifier]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. +Calls \code{\link[RWeka:Weka_interfaces]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. } \section{Initial parameter values}{ @@ -157,6 +157,7 @@ damirpolat
                                Inherited methods
                                • mlr3::Learner$base_learner()
                                • +
                                • mlr3::Learner$encapsulate()
                                • mlr3::Learner$format()
                                • mlr3::Learner$help()
                                • mlr3::Learner$predict()
                                • diff --git a/man/mlr_learners_classif.earth.Rd b/man/mlr_learners_classif.earth.Rd index 42757b2a5..d195da627 100644 --- a/man/mlr_learners_classif.earth.Rd +++ b/man/mlr_learners_classif.earth.Rd @@ -133,6 +133,7 @@ pkopper
                                  Inherited methods
                                  • mlr3::Learner$base_learner()
                                  • +
                                  • mlr3::Learner$encapsulate()
                                  • mlr3::Learner$format()
                                  • mlr3::Learner$help()
                                  • mlr3::Learner$predict()
                                  • diff --git a/man/mlr_learners_classif.fnn.Rd b/man/mlr_learners_classif.fnn.Rd index 9feb492cc..446eedb26 100644 --- a/man/mlr_learners_classif.fnn.Rd +++ b/man/mlr_learners_classif.fnn.Rd @@ -93,6 +93,7 @@ be-marc
                                    Inherited methods
                                    • mlr3::Learner$base_learner()
                                    • +
                                    • mlr3::Learner$encapsulate()
                                    • mlr3::Learner$format()
                                    • mlr3::Learner$help()
                                    • mlr3::Learner$predict()
                                    • diff --git a/man/mlr_learners_classif.gam.Rd b/man/mlr_learners_classif.gam.Rd index c87db492c..f9c69982b 100644 --- a/man/mlr_learners_classif.gam.Rd +++ b/man/mlr_learners_classif.gam.Rd @@ -82,6 +82,18 @@ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{ } } +\examples{ +\dontshow{if (requireNamespace("mgcv", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +# simple example +t = mlr3::tsk("spam")$filter(1:1000) +l = mlr3::lrn("classif.gam") +l$param_set$set_values( + formula = type ~ s(george, k = 3) + s(charDollar, k = 3) + s(edu) +) +l$train(t) +l$model +\dontshow{\}) # examplesIf} +} \references{ Hastie, J T, Tibshirani, J R (2017). \emph{Generalized additive models}. @@ -107,6 +119,7 @@ JazzyPierrot
                                      Inherited methods
                                      • mlr3::Learner$base_learner()
                                      • +
                                      • mlr3::Learner$encapsulate()
                                      • mlr3::Learner$format()
                                      • mlr3::Learner$help()
                                      • mlr3::Learner$predict()
                                      • diff --git a/man/mlr_learners_classif.gamboost.Rd b/man/mlr_learners_classif.gamboost.Rd index 34bfaacfc..2417c4652 100644 --- a/man/mlr_learners_classif.gamboost.Rd +++ b/man/mlr_learners_classif.gamboost.Rd @@ -104,6 +104,7 @@ be-marc
                                        Inherited methods
                                        • mlr3::Learner$base_learner()
                                        • +
                                        • mlr3::Learner$encapsulate()
                                        • mlr3::Learner$format()
                                        • mlr3::Learner$help()
                                        • mlr3::Learner$predict()
                                        • diff --git a/man/mlr_learners_classif.gausspr.Rd b/man/mlr_learners_classif.gausspr.Rd index 0337ba170..d8847b5a7 100644 --- a/man/mlr_learners_classif.gausspr.Rd +++ b/man/mlr_learners_classif.gausspr.Rd @@ -106,6 +106,7 @@ RaphaelS1
                                          Inherited methods
                                          • mlr3::Learner$base_learner()
                                          • +
                                          • mlr3::Learner$encapsulate()
                                          • mlr3::Learner$format()
                                          • mlr3::Learner$help()
                                          • mlr3::Learner$predict()
                                          • diff --git a/man/mlr_learners_classif.gbm.Rd b/man/mlr_learners_classif.gbm.Rd index cced88931..10af0a77e 100644 --- a/man/mlr_learners_classif.gbm.Rd +++ b/man/mlr_learners_classif.gbm.Rd @@ -68,7 +68,7 @@ ids = mlr3::partition(task) learner$train(task, row_ids = ids$train) print(learner$model) -print(learner$importance) +print(learner$importance()) # Make predictions for the test rows predictions = learner$predict(task, row_ids = ids$test) @@ -111,6 +111,7 @@ be-marc
                                            Inherited methods
                                            • mlr3::Learner$base_learner()
                                            • +
                                            • mlr3::Learner$encapsulate()
                                            • mlr3::Learner$format()
                                            • mlr3::Learner$help()
                                            • mlr3::Learner$predict()
                                            • diff --git a/man/mlr_learners_classif.glmboost.Rd b/man/mlr_learners_classif.glmboost.Rd index 06be6d6eb..048a800c5 100644 --- a/man/mlr_learners_classif.glmboost.Rd +++ b/man/mlr_learners_classif.glmboost.Rd @@ -104,6 +104,7 @@ be-marc
                                              Inherited methods
                                              • mlr3::Learner$base_learner()
                                              • +
                                              • mlr3::Learner$encapsulate()
                                              • mlr3::Learner$format()
                                              • mlr3::Learner$help()
                                              • mlr3::Learner$predict()
                                              • diff --git a/man/mlr_learners_classif.glmer.Rd b/man/mlr_learners_classif.glmer.Rd index a633c2748..c563294a2 100644 --- a/man/mlr_learners_classif.glmer.Rd +++ b/man/mlr_learners_classif.glmer.Rd @@ -132,6 +132,7 @@ sebffischer
                                                Inherited methods
                                                • mlr3::Learner$base_learner()
                                                • +
                                                • mlr3::Learner$encapsulate()
                                                • mlr3::Learner$format()
                                                • mlr3::Learner$help()
                                                • mlr3::Learner$predict()
                                                • diff --git a/man/mlr_learners_classif.imbalanced_rfsrc.Rd b/man/mlr_learners_classif.imbalanced_rfsrc.Rd index 8635a7aa4..b0595a89f 100644 --- a/man/mlr_learners_classif.imbalanced_rfsrc.Rd +++ b/man/mlr_learners_classif.imbalanced_rfsrc.Rd @@ -30,7 +30,7 @@ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{ \section{Parameters}{ \tabular{lllll}{ Id \tab Type \tab Default \tab Levels \tab Range \cr - ntree \tab integer \tab 3000 \tab \tab \eqn{[1, \infty)}{[1, Inf)} \cr + ntree \tab integer \tab 500 \tab \tab \eqn{[1, \infty)}{[1, Inf)} \cr method \tab character \tab rfq \tab rfq, brf, standard \tab - \cr block.size \tab integer \tab 10 \tab \tab \eqn{[1, \infty)}{[1, Inf)} \cr fast \tab logical \tab FALSE \tab TRUE, FALSE \tab - \cr @@ -76,32 +76,25 @@ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{ \section{Custom mlr3 parameters}{ \itemize{ -\item \code{mtry}: -\itemize{ -\item This hyperparameter can alternatively be set via the added hyperparameter \code{mtry.ratio} -as \code{mtry = max(ceiling(mtry.ratio * n_features), 1)}. +\item \code{mtry}: This hyperparameter can alternatively be set via the added +hyperparameter \code{mtry.ratio} as \code{mtry = max(ceiling(mtry.ratio * n_features), 1)}. Note that \code{mtry} and \code{mtry.ratio} are mutually exclusive. -} -\item \code{sampsize}: -\itemize{ -\item This hyperparameter can alternatively be set via the added hyperparameter \code{sampsize.ratio} -as \code{sampsize = max(ceiling(sampsize.ratio * n_obs), 1)}. +\item \code{sampsize}: This hyperparameter can alternatively be set via the added +hyperparameter \code{sampsize.ratio} as \code{sampsize = max(ceiling(sampsize.ratio * n_obs), 1)}. Note that \code{sampsize} and \code{sampsize.ratio} are mutually exclusive. -} -\item \code{cores}: -This value is set as the option \code{rf.cores} during training and is set to 1 by default. +\item \code{cores}: This value is set as the option \code{rf.cores} during training and is +set to 1 by default. } } \examples{ -\dontshow{if (mlr3misc::require_namespaces(lrn("classif.imbalanced_rfsrc")$packages, quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (requireNamespace("randomForestSRC", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} # Define the Learner -learner = mlr3::lrn("classif.imbalanced_rfsrc") +learner = mlr3::lrn("classif.imbalanced_rfsrc", importance = "TRUE") print(learner) # Define a Task task = mlr3::tsk("sonar") - # Create train and test set ids = mlr3::partition(task) @@ -109,7 +102,7 @@ ids = mlr3::partition(task) learner$train(task, row_ids = ids$train) print(learner$model) -print(learner$importance) +print(learner$importance()) # Make predictions for the test rows predictions = learner$predict(task, row_ids = ids$test) @@ -159,6 +152,7 @@ HarutyunyanLiana
                                                  Inherited methods
                                                  • mlr3::Learner$base_learner()
                                                  • +
                                                  • mlr3::Learner$encapsulate()
                                                  • mlr3::Learner$format()
                                                  • mlr3::Learner$help()
                                                  • mlr3::Learner$predict()
                                                  • diff --git a/man/mlr_learners_classif.kstar.Rd b/man/mlr_learners_classif.kstar.Rd index e22da9f5f..07ed0ce35 100644 --- a/man/mlr_learners_classif.kstar.Rd +++ b/man/mlr_learners_classif.kstar.Rd @@ -7,7 +7,7 @@ \description{ Instance-based classifier which differs from other instance-based learners in that it uses an entropy-based distance function. -Calls \code{\link[RWeka:make_Weka_classifier]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. +Calls \code{\link[RWeka:Weka_interfaces]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. } \section{Custom mlr3 parameters}{ @@ -125,6 +125,7 @@ damirpolat
                                                    Inherited methods
                                                    • mlr3::Learner$base_learner()
                                                    • +
                                                    • mlr3::Learner$encapsulate()
                                                    • mlr3::Learner$format()
                                                    • mlr3::Learner$help()
                                                    • mlr3::Learner$predict()
                                                    • diff --git a/man/mlr_learners_classif.ksvm.Rd b/man/mlr_learners_classif.ksvm.Rd index 29ea9c29b..0753d3317 100644 --- a/man/mlr_learners_classif.ksvm.Rd +++ b/man/mlr_learners_classif.ksvm.Rd @@ -104,6 +104,7 @@ mboecker
                                                      Inherited methods
                                                      • mlr3::Learner$base_learner()
                                                      • +
                                                      • mlr3::Learner$encapsulate()
                                                      • mlr3::Learner$format()
                                                      • mlr3::Learner$help()
                                                      • mlr3::Learner$predict()
                                                      • diff --git a/man/mlr_learners_classif.liblinear.Rd b/man/mlr_learners_classif.liblinear.Rd index aae01dbd4..7e6dc5cdc 100644 --- a/man/mlr_learners_classif.liblinear.Rd +++ b/man/mlr_learners_classif.liblinear.Rd @@ -118,6 +118,7 @@ be-marc
                                                        Inherited methods
                                                        • mlr3::Learner$base_learner()
                                                        • +
                                                        • mlr3::Learner$encapsulate()
                                                        • mlr3::Learner$format()
                                                        • mlr3::Learner$help()
                                                        • mlr3::Learner$predict()
                                                        • diff --git a/man/mlr_learners_classif.lightgbm.Rd b/man/mlr_learners_classif.lightgbm.Rd index c22e1751b..d3fed1651 100644 --- a/man/mlr_learners_classif.lightgbm.Rd +++ b/man/mlr_learners_classif.lightgbm.Rd @@ -59,6 +59,7 @@ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{ neg_bagging_fraction \tab numeric \tab 1 \tab \tab \eqn{[0, 1]}{[0, 1]} \cr bagging_freq \tab integer \tab 0 \tab \tab \eqn{[0, \infty)}{[0, Inf)} \cr bagging_seed \tab integer \tab 3 \tab \tab \eqn{(-\infty, \infty)}{(-Inf, Inf)} \cr + bagging_by_query \tab logical \tab FALSE \tab TRUE, FALSE \tab - \cr feature_fraction \tab numeric \tab 1 \tab \tab \eqn{[0, 1]}{[0, 1]} \cr feature_fraction_bynode \tab numeric \tab 1 \tab \tab \eqn{[0, 1]}{[0, 1]} \cr feature_fraction_seed \tab integer \tab 2 \tab \tab \eqn{(-\infty, \infty)}{(-Inf, Inf)} \cr @@ -155,14 +156,11 @@ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{ \item Initial value: -1L \item Reason for change: Prevents accidental conflicts with mlr messaging system. } -} -} - -\section{Custom mlr3 defaults}{ - -\itemize{ \item \code{objective}: -Depending if the task is binary / multiclass, the default is \code{"binary"} or \code{"multiclasss"}. +\itemize{ +\item Depends on the task: if binary classification, then this parameter is set to +\code{"binary"}, otherwise \code{"multiclasss"} and cannot be changed. +} } } @@ -199,7 +197,7 @@ ids = mlr3::partition(task) learner$train(task, row_ids = ids$train) print(learner$model) -print(learner$importance) +print(learner$importance()) # Make predictions for the test rows predictions = learner$predict(task, row_ids = ids$test) @@ -254,6 +252,7 @@ Extracted from \code{model$evaluation_log}}
                                                          Inherited methods
                                                          • mlr3::Learner$base_learner()
                                                          • +
                                                          • mlr3::Learner$encapsulate()
                                                          • mlr3::Learner$format()
                                                          • mlr3::Learner$help()
                                                          • mlr3::Learner$predict()
                                                          • diff --git a/man/mlr_learners_classif.logistic.Rd b/man/mlr_learners_classif.logistic.Rd index 96b077bb4..8d4dfc2bb 100644 --- a/man/mlr_learners_classif.logistic.Rd +++ b/man/mlr_learners_classif.logistic.Rd @@ -6,7 +6,7 @@ \title{Classification Logistic Regression Learner} \description{ Multinomial Logistic Regression model with a ridge estimator. -Calls \code{\link[RWeka:Logistic]{RWeka::Logistic()}} from \CRANpkg{RWeka}. +Calls \code{\link[RWeka:Weka_classifier_functions]{RWeka::Logistic()}} from \CRANpkg{RWeka}. } \section{Custom mlr3 parameters}{ @@ -124,6 +124,7 @@ damirpolat
                                                            Inherited methods
                                                            • mlr3::Learner$base_learner()
                                                            • +
                                                            • mlr3::Learner$encapsulate()
                                                            • mlr3::Learner$format()
                                                            • mlr3::Learner$help()
                                                            • mlr3::Learner$predict()
                                                            • diff --git a/man/mlr_learners_classif.lssvm.Rd b/man/mlr_learners_classif.lssvm.Rd index 99b4fe10a..bc8ab07da 100644 --- a/man/mlr_learners_classif.lssvm.Rd +++ b/man/mlr_learners_classif.lssvm.Rd @@ -113,6 +113,7 @@ RaphaelS1
                                                              Inherited methods
                                                              • mlr3::Learner$base_learner()
                                                              • +
                                                              • mlr3::Learner$encapsulate()
                                                              • mlr3::Learner$format()
                                                              • mlr3::Learner$help()
                                                              • mlr3::Learner$predict()
                                                              • diff --git a/man/mlr_learners_classif.mob.Rd b/man/mlr_learners_classif.mob.Rd index 96bdad18f..865eead8a 100644 --- a/man/mlr_learners_classif.mob.Rd +++ b/man/mlr_learners_classif.mob.Rd @@ -66,6 +66,7 @@ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{ } \examples{ +\dontshow{if (requireNamespace("partykit", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} library(mlr3) logit_ = function(y, x, start = NULL, weights = NULL, offset = NULL, ...) { glm(y ~ 1, family = binomial, start = start, ...) @@ -92,6 +93,7 @@ learner$param_set$values$predict_fun = predict_fun ids = partition(task) learner$train(task, row_ids = ids$train) learner$predict(task, row_ids = ids$test) +\dontshow{\}) # examplesIf} } \references{ Hothorn T, Zeileis A (2015). @@ -132,6 +134,7 @@ sumny
                                                                Inherited methods
                                                                • mlr3::Learner$base_learner()
                                                                • +
                                                                • mlr3::Learner$encapsulate()
                                                                • mlr3::Learner$format()
                                                                • mlr3::Learner$help()
                                                                • mlr3::Learner$predict()
                                                                • diff --git a/man/mlr_learners_classif.multilayer_perceptron.Rd b/man/mlr_learners_classif.multilayer_perceptron.Rd index 90b9b8a0c..e2f180155 100644 --- a/man/mlr_learners_classif.multilayer_perceptron.Rd +++ b/man/mlr_learners_classif.multilayer_perceptron.Rd @@ -6,7 +6,7 @@ \title{Classification MultilayerPerceptron Learner} \description{ Classifier that uses backpropagation to learn a multi-layer perceptron. -Calls \code{\link[RWeka:make_Weka_classifier]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. +Calls \code{\link[RWeka:Weka_interfaces]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. } \section{Custom mlr3 parameters}{ @@ -134,6 +134,7 @@ damirpolat
                                                                  Inherited methods
                                                                  • mlr3::Learner$base_learner()
                                                                  • +
                                                                  • mlr3::Learner$encapsulate()
                                                                  • mlr3::Learner$format()
                                                                  • mlr3::Learner$help()
                                                                  • mlr3::Learner$predict()
                                                                  • diff --git a/man/mlr_learners_classif.naive_bayes_multinomial.Rd b/man/mlr_learners_classif.naive_bayes_multinomial.Rd index 80c226e35..9faee0214 100644 --- a/man/mlr_learners_classif.naive_bayes_multinomial.Rd +++ b/man/mlr_learners_classif.naive_bayes_multinomial.Rd @@ -6,7 +6,7 @@ \title{Classification Multinomial Naive Bayes Learner From Weka} \description{ Multinomial Naive Bayes classifier. -Calls \code{\link[RWeka:make_Weka_classifier]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. +Calls \code{\link[RWeka:Weka_interfaces]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. } \section{Custom mlr3 parameters}{ @@ -119,6 +119,7 @@ damirpolat
                                                                    Inherited methods
                                                                    • mlr3::Learner$base_learner()
                                                                    • +
                                                                    • mlr3::Learner$encapsulate()
                                                                    • mlr3::Learner$format()
                                                                    • mlr3::Learner$help()
                                                                    • mlr3::Learner$predict()
                                                                    • diff --git a/man/mlr_learners_classif.naive_bayes_weka.Rd b/man/mlr_learners_classif.naive_bayes_weka.Rd index b234a3219..d54d2ab1d 100644 --- a/man/mlr_learners_classif.naive_bayes_weka.Rd +++ b/man/mlr_learners_classif.naive_bayes_weka.Rd @@ -6,7 +6,7 @@ \title{Classification Naive Bayes Learner From Weka} \description{ Naive Bayes Classifier Using Estimator Classes. -Calls \code{\link[RWeka:make_Weka_classifier]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. +Calls \code{\link[RWeka:Weka_interfaces]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. } \section{Custom mlr3 parameters}{ @@ -124,6 +124,7 @@ damirpolat
                                                                      Inherited methods
                                                                      • mlr3::Learner$base_learner()
                                                                      • +
                                                                      • mlr3::Learner$encapsulate()
                                                                      • mlr3::Learner$format()
                                                                      • mlr3::Learner$help()
                                                                      • mlr3::Learner$predict()
                                                                      • diff --git a/man/mlr_learners_classif.priority_lasso.Rd b/man/mlr_learners_classif.priority_lasso.Rd index 47bf3d4a5..3e62b11c0 100644 --- a/man/mlr_learners_classif.priority_lasso.Rd +++ b/man/mlr_learners_classif.priority_lasso.Rd @@ -8,6 +8,13 @@ Patient outcome prediction based on multi-omics data taking practitioners’ preferences into account. Calls \code{\link[prioritylasso:prioritylasso]{prioritylasso::prioritylasso()}} from \CRANpkg{prioritylasso}. } +\section{Initial parameter values}{ + +\itemize{ +\item \code{family} is set to \code{"binomial"} and canno be changed +} +} + \section{Dictionary}{ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{lrn()}: @@ -136,6 +143,7 @@ HarutyunyanLiana
                                                                        Inherited methods
                                                                        • mlr3::Learner$base_learner()
                                                                        • +
                                                                        • mlr3::Learner$encapsulate()
                                                                        • mlr3::Learner$format()
                                                                        • mlr3::Learner$help()
                                                                        • mlr3::Learner$predict()
                                                                        • @@ -160,7 +168,7 @@ Creates a new instance of this \link[R6:R6Class]{R6} class. \if{html}{\out{}} \if{latex}{\out{\hypertarget{method-LearnerClassifPriorityLasso-selected_features}{}}} \subsection{Method \code{selected_features()}}{ -Selected features, i.e. those where the coefficient is positive. +Selected features, i.e. those where the coefficient is non-zero. \subsection{Usage}{ \if{html}{\out{
                                                                          }}\preformatted{LearnerClassifPriorityLasso$selected_features()}\if{html}{\out{
                                                                          }} } diff --git a/man/mlr_learners_classif.randomForest.Rd b/man/mlr_learners_classif.randomForest.Rd index 9cf8637dc..e87117ab2 100644 --- a/man/mlr_learners_classif.randomForest.Rd +++ b/man/mlr_learners_classif.randomForest.Rd @@ -52,14 +52,13 @@ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{ } \examples{ -\dontshow{if (mlr3misc::require_namespaces(lrn("classif.randomForest")$packages, quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (requireNamespace("randomForest", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} # Define the Learner -learner = mlr3::lrn("classif.randomForest") +learner = mlr3::lrn("classif.randomForest", importance = "accuracy") print(learner) # Define a Task task = mlr3::tsk("sonar") - # Create train and test set ids = mlr3::partition(task) @@ -67,7 +66,7 @@ ids = mlr3::partition(task) learner$train(task, row_ids = ids$train) print(learner$model) -print(learner$importance) +print(learner$importance()) # Make predictions for the test rows predictions = learner$predict(task, row_ids = ids$test) @@ -112,6 +111,7 @@ pat-s
                                                                          Inherited methods
                                                                          • mlr3::Learner$base_learner()
                                                                          • +
                                                                          • mlr3::Learner$encapsulate()
                                                                          • mlr3::Learner$format()
                                                                          • mlr3::Learner$help()
                                                                          • mlr3::Learner$predict()
                                                                          • diff --git a/man/mlr_learners_classif.random_forest_weka.Rd b/man/mlr_learners_classif.random_forest_weka.Rd index f0f5d9d90..95497b5d9 100644 --- a/man/mlr_learners_classif.random_forest_weka.Rd +++ b/man/mlr_learners_classif.random_forest_weka.Rd @@ -6,7 +6,7 @@ \title{Classification Random Forest Learner from Weka} \description{ Class for constructing a random forest. -Calls \code{\link[RWeka:make_Weka_classifier]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. +Calls \code{\link[RWeka:Weka_interfaces]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. } \section{Custom mlr3 parameters}{ @@ -154,6 +154,7 @@ damirpolat
                                                                            Inherited methods
                                                                            • mlr3::Learner$base_learner()
                                                                            • +
                                                                            • mlr3::Learner$encapsulate()
                                                                            • mlr3::Learner$format()
                                                                            • mlr3::Learner$help()
                                                                            • mlr3::Learner$predict()
                                                                            • diff --git a/man/mlr_learners_classif.random_tree.Rd b/man/mlr_learners_classif.random_tree.Rd index 53bdac2c7..2cd4990bf 100644 --- a/man/mlr_learners_classif.random_tree.Rd +++ b/man/mlr_learners_classif.random_tree.Rd @@ -6,7 +6,7 @@ \title{Classification Random Tree Learner} \description{ Tree that considers K randomly chosen attributes at each node. -Calls \code{\link[RWeka:make_Weka_classifier]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. +Calls \code{\link[RWeka:Weka_interfaces]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. } \section{Custom mlr3 parameters}{ @@ -124,6 +124,7 @@ damirpolat
                                                                              Inherited methods
                                                                              • mlr3::Learner$base_learner()
                                                                              • +
                                                                              • mlr3::Learner$encapsulate()
                                                                              • mlr3::Learner$format()
                                                                              • mlr3::Learner$help()
                                                                              • mlr3::Learner$predict()
                                                                              • diff --git a/man/mlr_learners_classif.reptree.Rd b/man/mlr_learners_classif.reptree.Rd index bb7c26f49..fdf4c18c6 100644 --- a/man/mlr_learners_classif.reptree.Rd +++ b/man/mlr_learners_classif.reptree.Rd @@ -6,7 +6,7 @@ \title{Classification Decision Tree Learner} \description{ Fast decision tree learner. -Calls \code{\link[RWeka:make_Weka_classifier]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. +Calls \code{\link[RWeka:Weka_interfaces]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. } \section{Custom mlr3 parameters}{ @@ -124,6 +124,7 @@ damirpolat
                                                                                Inherited methods
                                                                                • mlr3::Learner$base_learner()
                                                                                • +
                                                                                • mlr3::Learner$encapsulate()
                                                                                • mlr3::Learner$format()
                                                                                • mlr3::Learner$help()
                                                                                • mlr3::Learner$predict()
                                                                                • diff --git a/man/mlr_learners_classif.rfsrc.Rd b/man/mlr_learners_classif.rfsrc.Rd index 3a3af56fe..cbaf467c2 100644 --- a/man/mlr_learners_classif.rfsrc.Rd +++ b/man/mlr_learners_classif.rfsrc.Rd @@ -29,7 +29,7 @@ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{ \section{Parameters}{ \tabular{lllll}{ Id \tab Type \tab Default \tab Levels \tab Range \cr - ntree \tab integer \tab 1000 \tab \tab \eqn{[1, \infty)}{[1, Inf)} \cr + ntree \tab integer \tab 500 \tab \tab \eqn{[1, \infty)}{[1, Inf)} \cr mtry \tab integer \tab - \tab \tab \eqn{[1, \infty)}{[1, Inf)} \cr mtry.ratio \tab numeric \tab - \tab \tab \eqn{[0, 1]}{[0, 1]} \cr nodesize \tab integer \tab 15 \tab \tab \eqn{[1, \infty)}{[1, Inf)} \cr @@ -72,32 +72,25 @@ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{ \section{Custom mlr3 parameters}{ \itemize{ -\item \code{mtry}: -\itemize{ -\item This hyperparameter can alternatively be set via the added hyperparameter \code{mtry.ratio} -as \code{mtry = max(ceiling(mtry.ratio * n_features), 1)}. +\item \code{mtry}: This hyperparameter can alternatively be set via the added +hyperparameter \code{mtry.ratio} as \code{mtry = max(ceiling(mtry.ratio * n_features), 1)}. Note that \code{mtry} and \code{mtry.ratio} are mutually exclusive. -} -\item \code{sampsize}: -\itemize{ -\item This hyperparameter can alternatively be set via the added hyperparameter \code{sampsize.ratio} -as \code{sampsize = max(ceiling(sampsize.ratio * n_obs), 1)}. +\item \code{sampsize}: This hyperparameter can alternatively be set via the added +hyperparameter \code{sampsize.ratio} as \code{sampsize = max(ceiling(sampsize.ratio * n_obs), 1)}. Note that \code{sampsize} and \code{sampsize.ratio} are mutually exclusive. -} -\item \code{cores}: -This value is set as the option \code{rf.cores} during training and is set to 1 by default. +\item \code{cores}: This value is set as the option \code{rf.cores} during training and is +set to 1 by default. } } \examples{ -\dontshow{if (mlr3misc::require_namespaces(lrn("classif.rfsrc")$packages, quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (requireNamespace("randomForestSRC", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} # Define the Learner -learner = mlr3::lrn("classif.rfsrc") +learner = mlr3::lrn("classif.rfsrc", importance = "TRUE") print(learner) # Define a Task task = mlr3::tsk("sonar") - # Create train and test set ids = mlr3::partition(task) @@ -105,7 +98,7 @@ ids = mlr3::partition(task) learner$train(task, row_ids = ids$train) print(learner$model) -print(learner$importance) +print(learner$importance()) # Make predictions for the test rows predictions = learner$predict(task, row_ids = ids$test) @@ -151,6 +144,7 @@ RaphaelS1
                                                                                  Inherited methods
                                                                                  • mlr3::Learner$base_learner()
                                                                                  • +
                                                                                  • mlr3::Learner$encapsulate()
                                                                                  • mlr3::Learner$format()
                                                                                  • mlr3::Learner$help()
                                                                                  • mlr3::Learner$predict()
                                                                                  • diff --git a/man/mlr_learners_classif.rpf.Rd b/man/mlr_learners_classif.rpf.Rd index 18082c359..efc671cf1 100644 --- a/man/mlr_learners_classif.rpf.Rd +++ b/man/mlr_learners_classif.rpf.Rd @@ -141,6 +141,7 @@ jemus42
                                                                                    Inherited methods
                                                                                    • mlr3::Learner$base_learner()
                                                                                    • +
                                                                                    • mlr3::Learner$encapsulate()
                                                                                    • mlr3::Learner$format()
                                                                                    • mlr3::Learner$help()
                                                                                    • mlr3::Learner$predict()
                                                                                    • diff --git a/man/mlr_learners_classif.sgd.Rd b/man/mlr_learners_classif.sgd.Rd index fd1d32f62..0ffc8236d 100644 --- a/man/mlr_learners_classif.sgd.Rd +++ b/man/mlr_learners_classif.sgd.Rd @@ -6,7 +6,7 @@ \title{Classification Stochastic Gradient Descent Learner} \description{ Stochastic Gradient Descent for learning various linear models. -Calls \code{\link[RWeka:make_Weka_classifier]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. +Calls \code{\link[RWeka:Weka_interfaces]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. } \section{Initial parameter values}{ @@ -136,6 +136,7 @@ damirpolat
                                                                                      Inherited methods
                                                                                      • mlr3::Learner$base_learner()
                                                                                      • +
                                                                                      • mlr3::Learner$encapsulate()
                                                                                      • mlr3::Learner$format()
                                                                                      • mlr3::Learner$help()
                                                                                      • mlr3::Learner$predict()
                                                                                      • diff --git a/man/mlr_learners_classif.simple_logistic.Rd b/man/mlr_learners_classif.simple_logistic.Rd index 11062d435..9ee56b31b 100644 --- a/man/mlr_learners_classif.simple_logistic.Rd +++ b/man/mlr_learners_classif.simple_logistic.Rd @@ -6,7 +6,7 @@ \title{Classification SimpleLogistic Learner} \description{ LogitBoost with simple regression functions as base learners. -Calls \code{\link[RWeka:make_Weka_classifier]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. +Calls \code{\link[RWeka:Weka_interfaces]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. } \section{Custom mlr3 parameters}{ @@ -132,6 +132,7 @@ damirpolat
                                                                                        Inherited methods
                                                                                        • mlr3::Learner$base_learner()
                                                                                        • +
                                                                                        • mlr3::Learner$encapsulate()
                                                                                        • mlr3::Learner$format()
                                                                                        • mlr3::Learner$help()
                                                                                        • mlr3::Learner$predict()
                                                                                        • diff --git a/man/mlr_learners_classif.smo.Rd b/man/mlr_learners_classif.smo.Rd index 0ee9cb9ef..9560a81ef 100644 --- a/man/mlr_learners_classif.smo.Rd +++ b/man/mlr_learners_classif.smo.Rd @@ -6,7 +6,7 @@ \title{Classification Support Vector Machine Learner} \description{ Support Vector classifier trained with John Platt's sequential minimal optimization algorithm. -Calls \code{\link[RWeka:SMO]{RWeka::SMO()}} from \CRANpkg{RWeka}. +Calls \code{\link[RWeka:Weka_classifier_functions]{RWeka::SMO()}} from \CRANpkg{RWeka}. } \section{Custom mlr3 parameters}{ @@ -171,6 +171,7 @@ damirpolat
                                                                                          Inherited methods
                                                                                          • mlr3::Learner$base_learner()
                                                                                          • +
                                                                                          • mlr3::Learner$encapsulate()
                                                                                          • mlr3::Learner$format()
                                                                                          • mlr3::Learner$help()
                                                                                          • mlr3::Learner$predict()
                                                                                          • diff --git a/man/mlr_learners_classif.voted_perceptron.Rd b/man/mlr_learners_classif.voted_perceptron.Rd index 6303925a8..4058a82b6 100644 --- a/man/mlr_learners_classif.voted_perceptron.Rd +++ b/man/mlr_learners_classif.voted_perceptron.Rd @@ -6,7 +6,7 @@ \title{Classification Voted Perceptron Learner} \description{ Voted Perceptron Algorithm by Freund and Schapire. -Calls \code{\link[RWeka:make_Weka_classifier]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. +Calls \code{\link[RWeka:Weka_interfaces]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. } \section{Custom mlr3 parameters}{ @@ -125,6 +125,7 @@ damirpolat
                                                                                            Inherited methods
                                                                                            • mlr3::Learner$base_learner()
                                                                                            • +
                                                                                            • mlr3::Learner$encapsulate()
                                                                                            • mlr3::Learner$format()
                                                                                            • mlr3::Learner$help()
                                                                                            • mlr3::Learner$predict()
                                                                                            • diff --git a/man/mlr_learners_dens.kde_ks.Rd b/man/mlr_learners_dens.kde_ks.Rd index 07430038c..fff672251 100644 --- a/man/mlr_learners_dens.kde_ks.Rd +++ b/man/mlr_learners_dens.kde_ks.Rd @@ -107,6 +107,7 @@ RaphaelS1
                                                                                              Inherited methods
                                                                                              • mlr3::Learner$base_learner()
                                                                                              • +
                                                                                              • mlr3::Learner$encapsulate()
                                                                                              • mlr3::Learner$format()
                                                                                              • mlr3::Learner$help()
                                                                                              • mlr3::Learner$predict()
                                                                                              • diff --git a/man/mlr_learners_dens.locfit.Rd b/man/mlr_learners_dens.locfit.Rd index 89bd6b2c4..6b27255ec 100644 --- a/man/mlr_learners_dens.locfit.Rd +++ b/man/mlr_learners_dens.locfit.Rd @@ -104,6 +104,7 @@ RaphaelS1
                                                                                                Inherited methods
                                                                                                • mlr3::Learner$base_learner()
                                                                                                • +
                                                                                                • mlr3::Learner$encapsulate()
                                                                                                • mlr3::Learner$format()
                                                                                                • mlr3::Learner$help()
                                                                                                • mlr3::Learner$predict()
                                                                                                • diff --git a/man/mlr_learners_dens.logspline.Rd b/man/mlr_learners_dens.logspline.Rd index 655f0337c..b131ab776 100644 --- a/man/mlr_learners_dens.logspline.Rd +++ b/man/mlr_learners_dens.logspline.Rd @@ -99,6 +99,7 @@ RaphaelS1
                                                                                                  Inherited methods
                                                                                                  • mlr3::Learner$base_learner()
                                                                                                  • +
                                                                                                  • mlr3::Learner$encapsulate()
                                                                                                  • mlr3::Learner$format()
                                                                                                  • mlr3::Learner$help()
                                                                                                  • mlr3::Learner$predict()
                                                                                                  • diff --git a/man/mlr_learners_dens.mixed.Rd b/man/mlr_learners_dens.mixed.Rd index 790973239..51201c1ba 100644 --- a/man/mlr_learners_dens.mixed.Rd +++ b/man/mlr_learners_dens.mixed.Rd @@ -6,7 +6,7 @@ \title{Density Mixed Data Kernel Learner} \description{ Density estimator for discrete and continuous variables. -Calls \code{\link[np:npudens]{np::npudens()}} from \CRANpkg{np}. +Calls \code{\link[np:np.density]{np::npudens()}} from \CRANpkg{np}. } \section{Dictionary}{ @@ -119,6 +119,7 @@ RaphaelS1
                                                                                                    Inherited methods
                                                                                                    • mlr3::Learner$base_learner()
                                                                                                    • +
                                                                                                    • mlr3::Learner$encapsulate()
                                                                                                    • mlr3::Learner$format()
                                                                                                    • mlr3::Learner$help()
                                                                                                    • mlr3::Learner$predict()
                                                                                                    • diff --git a/man/mlr_learners_dens.nonpar.Rd b/man/mlr_learners_dens.nonpar.Rd index 46be95736..bea7f401e 100644 --- a/man/mlr_learners_dens.nonpar.Rd +++ b/man/mlr_learners_dens.nonpar.Rd @@ -99,6 +99,7 @@ RaphaelS1
                                                                                                      Inherited methods
                                                                                                      • mlr3::Learner$base_learner()
                                                                                                      • +
                                                                                                      • mlr3::Learner$encapsulate()
                                                                                                      • mlr3::Learner$format()
                                                                                                      • mlr3::Learner$help()
                                                                                                      • mlr3::Learner$predict()
                                                                                                      • diff --git a/man/mlr_learners_dens.pen.Rd b/man/mlr_learners_dens.pen.Rd index e8b5156fd..b4096e231 100644 --- a/man/mlr_learners_dens.pen.Rd +++ b/man/mlr_learners_dens.pen.Rd @@ -99,6 +99,7 @@ RaphaelS1
                                                                                                        Inherited methods
                                                                                                        • mlr3::Learner$base_learner()
                                                                                                        • +
                                                                                                        • mlr3::Learner$encapsulate()
                                                                                                        • mlr3::Learner$format()
                                                                                                        • mlr3::Learner$help()
                                                                                                        • mlr3::Learner$predict()
                                                                                                        • diff --git a/man/mlr_learners_dens.plug.Rd b/man/mlr_learners_dens.plug.Rd index 494a597fd..e6e175de4 100644 --- a/man/mlr_learners_dens.plug.Rd +++ b/man/mlr_learners_dens.plug.Rd @@ -91,6 +91,7 @@ RaphaelS1
                                                                                                          Inherited methods
                                                                                                          • mlr3::Learner$base_learner()
                                                                                                          • +
                                                                                                          • mlr3::Learner$encapsulate()
                                                                                                          • mlr3::Learner$format()
                                                                                                          • mlr3::Learner$help()
                                                                                                          • mlr3::Learner$predict()
                                                                                                          • diff --git a/man/mlr_learners_dens.spline.Rd b/man/mlr_learners_dens.spline.Rd index c50a67358..08a923eda 100644 --- a/man/mlr_learners_dens.spline.Rd +++ b/man/mlr_learners_dens.spline.Rd @@ -104,6 +104,7 @@ RaphaelS1
                                                                                                            Inherited methods
                                                                                                            • mlr3::Learner$base_learner()
                                                                                                            • +
                                                                                                            • mlr3::Learner$encapsulate()
                                                                                                            • mlr3::Learner$format()
                                                                                                            • mlr3::Learner$help()
                                                                                                            • mlr3::Learner$predict()
                                                                                                            • diff --git a/man/mlr_learners_regr.IBk.Rd b/man/mlr_learners_regr.IBk.Rd index 811e44ff4..b1d8b2c92 100644 --- a/man/mlr_learners_regr.IBk.Rd +++ b/man/mlr_learners_regr.IBk.Rd @@ -6,7 +6,7 @@ \title{Regression IBk Learner} \description{ Instance based algorithm: K-nearest neighbours regression. -Calls \code{\link[RWeka:IBk]{RWeka::IBk()}} from \CRANpkg{RWeka}. +Calls \code{\link[RWeka:Weka_classifier_lazy]{RWeka::IBk()}} from \CRANpkg{RWeka}. } \section{Dictionary}{ @@ -134,6 +134,7 @@ henrifnk
                                                                                                              Inherited methods
                                                                                                              • mlr3::Learner$base_learner()
                                                                                                              • +
                                                                                                              • mlr3::Learner$encapsulate()
                                                                                                              • mlr3::Learner$format()
                                                                                                              • mlr3::Learner$help()
                                                                                                              • mlr3::Learner$predict()
                                                                                                              • diff --git a/man/mlr_learners_regr.M5Rules.Rd b/man/mlr_learners_regr.M5Rules.Rd index 2ddc3dd66..1dddf5055 100644 --- a/man/mlr_learners_regr.M5Rules.Rd +++ b/man/mlr_learners_regr.M5Rules.Rd @@ -7,7 +7,7 @@ \description{ Algorithm for inducing \href{https://en.wikipedia.org/wiki/Decision_list}{decision lists} from model trees. -Calls \code{\link[RWeka:M5Rules]{RWeka::M5Rules()}} from \CRANpkg{RWeka}. +Calls \code{\link[RWeka:Weka_classifier_rules]{RWeka::M5Rules()}} from \CRANpkg{RWeka}. } \section{Dictionary}{ @@ -127,6 +127,7 @@ henrifnk
                                                                                                                Inherited methods
                                                                                                                • mlr3::Learner$base_learner()
                                                                                                                • +
                                                                                                                • mlr3::Learner$encapsulate()
                                                                                                                • mlr3::Learner$format()
                                                                                                                • mlr3::Learner$help()
                                                                                                                • mlr3::Learner$predict()
                                                                                                                • diff --git a/man/mlr_learners_regr.abess.Rd b/man/mlr_learners_regr.abess.Rd index 1a676e4d2..09e27b809 100644 --- a/man/mlr_learners_regr.abess.Rd +++ b/man/mlr_learners_regr.abess.Rd @@ -62,6 +62,8 @@ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{ \itemize{ \item \code{num.threads}: This parameter is initialized to 1 (default is 0) to avoid conflicts with the mlr3 parallelization. +\item \code{family}: Depends on the task type, if the parameter \code{family} is \code{NULL}, it is set to \code{"binomial"} for binary +classification tasks and to \code{"multinomial"} for multiclass classification problems. } } @@ -119,6 +121,7 @@ abess-team
                                                                                                                  Inherited methods
                                                                                                                  • mlr3::Learner$base_learner()
                                                                                                                  • +
                                                                                                                  • mlr3::Learner$encapsulate()
                                                                                                                  • mlr3::Learner$format()
                                                                                                                  • mlr3::Learner$help()
                                                                                                                  • mlr3::Learner$predict()
                                                                                                                  • diff --git a/man/mlr_learners_regr.bart.Rd b/man/mlr_learners_regr.bart.Rd index ee363fe91..52c7974bc 100644 --- a/man/mlr_learners_regr.bart.Rd +++ b/man/mlr_learners_regr.bart.Rd @@ -59,13 +59,13 @@ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{ \section{Custom mlr3 parameters}{ \itemize{ -\item Parameter: offset +\item Parameter: \code{offset} \itemize{ \item The parameter is removed, because only \code{dbarts::bart2} allows an offset during training, and therefore the offset parameter in \code{dbarts:::predict.bart} is irrelevant for \code{dbarts::dbart}. } -\item Parameter: nchain, combineChains, combinechains +\item Parameter: \code{nchain}, \code{combineChains}, \code{combinechains} \itemize{ \item The parameters are removed as parallelization of multiple models is handled by future. } @@ -141,6 +141,7 @@ ck37
                                                                                                                    Inherited methods
                                                                                                                    • mlr3::Learner$base_learner()
                                                                                                                    • +
                                                                                                                    • mlr3::Learner$encapsulate()
                                                                                                                    • mlr3::Learner$format()
                                                                                                                    • mlr3::Learner$help()
                                                                                                                    • mlr3::Learner$predict()
                                                                                                                    • diff --git a/man/mlr_learners_regr.catboost.Rd b/man/mlr_learners_regr.catboost.Rd index a85eb8301..3f5e23dcd 100644 --- a/man/mlr_learners_regr.catboost.Rd +++ b/man/mlr_learners_regr.catboost.Rd @@ -156,7 +156,7 @@ ids = mlr3::partition(task) learner$train(task, row_ids = ids$train) print(learner$model) -print(learner$importance) +print(learner$importance()) # Make predictions for the test rows predictions = learner$predict(task, row_ids = ids$test) @@ -211,6 +211,7 @@ Extracted from \code{model$evaluation_log}}
                                                                                                                      Inherited methods
                                                                                                                      • mlr3::Learner$base_learner()
                                                                                                                      • +
                                                                                                                      • mlr3::Learner$encapsulate()
                                                                                                                      • mlr3::Learner$format()
                                                                                                                      • mlr3::Learner$help()
                                                                                                                      • mlr3::Learner$predict()
                                                                                                                      • diff --git a/man/mlr_learners_regr.cforest.Rd b/man/mlr_learners_regr.cforest.Rd index dd7f23690..ba2f688c9 100644 --- a/man/mlr_learners_regr.cforest.Rd +++ b/man/mlr_learners_regr.cforest.Rd @@ -156,6 +156,7 @@ sumny
                                                                                                                        Inherited methods
                                                                                                                        • mlr3::Learner$base_learner()
                                                                                                                        • +
                                                                                                                        • mlr3::Learner$encapsulate()
                                                                                                                        • mlr3::Learner$format()
                                                                                                                        • mlr3::Learner$help()
                                                                                                                        • mlr3::Learner$predict()
                                                                                                                        • diff --git a/man/mlr_learners_regr.ctree.Rd b/man/mlr_learners_regr.ctree.Rd index 00cf3f122..12810682f 100644 --- a/man/mlr_learners_regr.ctree.Rd +++ b/man/mlr_learners_regr.ctree.Rd @@ -134,6 +134,7 @@ sumny
                                                                                                                          Inherited methods
                                                                                                                          • mlr3::Learner$base_learner()
                                                                                                                          • +
                                                                                                                          • mlr3::Learner$encapsulate()
                                                                                                                          • mlr3::Learner$format()
                                                                                                                          • mlr3::Learner$help()
                                                                                                                          • mlr3::Learner$predict()
                                                                                                                          • diff --git a/man/mlr_learners_regr.cubist.Rd b/man/mlr_learners_regr.cubist.Rd index 25396403b..b1295adbf 100644 --- a/man/mlr_learners_regr.cubist.Rd +++ b/man/mlr_learners_regr.cubist.Rd @@ -7,7 +7,7 @@ \description{ Rule-based model that is an extension of Quinlan's M5 model tree. Each tree contains linear regression models at the terminal leaves. -Calls \code{\link[Cubist:cubist]{Cubist::cubist()}} from \CRANpkg{Cubist}. +Calls \code{\link[Cubist:cubist.default]{Cubist::cubist()}} from \CRANpkg{Cubist}. } \section{Dictionary}{ @@ -104,6 +104,7 @@ sumny
                                                                                                                            Inherited methods
                                                                                                                            • mlr3::Learner$base_learner()
                                                                                                                            • +
                                                                                                                            • mlr3::Learner$encapsulate()
                                                                                                                            • mlr3::Learner$format()
                                                                                                                            • mlr3::Learner$help()
                                                                                                                            • mlr3::Learner$predict()
                                                                                                                            • diff --git a/man/mlr_learners_regr.decision_stump.Rd b/man/mlr_learners_regr.decision_stump.Rd index e7a36544f..6611ca18f 100644 --- a/man/mlr_learners_regr.decision_stump.Rd +++ b/man/mlr_learners_regr.decision_stump.Rd @@ -6,7 +6,7 @@ \title{Regression Decision Stump Learner} \description{ Decision Stump Learner. -Calls \code{\link[RWeka:DecisionStump]{RWeka::DecisionStump()}} from \CRANpkg{RWeka}. +Calls \code{\link[RWeka:Weka_classifier_trees]{RWeka::DecisionStump()}} from \CRANpkg{RWeka}. } \section{Custom mlr3 parameters}{ @@ -116,6 +116,7 @@ damirpolat
                                                                                                                              Inherited methods
                                                                                                                              • mlr3::Learner$base_learner()
                                                                                                                              • +
                                                                                                                              • mlr3::Learner$encapsulate()
                                                                                                                              • mlr3::Learner$format()
                                                                                                                              • mlr3::Learner$help()
                                                                                                                              • mlr3::Learner$predict()
                                                                                                                              • diff --git a/man/mlr_learners_regr.decision_table.Rd b/man/mlr_learners_regr.decision_table.Rd index d5bb6c4e3..d814537e9 100644 --- a/man/mlr_learners_regr.decision_table.Rd +++ b/man/mlr_learners_regr.decision_table.Rd @@ -6,7 +6,7 @@ \title{Regression Decision Table Learner} \description{ Simple Decision Table majority regressor. -Calls \code{\link[RWeka:make_Weka_classifier]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. +Calls \code{\link[RWeka:Weka_interfaces]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. } \section{Initial parameter values}{ @@ -157,6 +157,7 @@ damirpolat
                                                                                                                                Inherited methods
                                                                                                                                • mlr3::Learner$base_learner()
                                                                                                                                • +
                                                                                                                                • mlr3::Learner$encapsulate()
                                                                                                                                • mlr3::Learner$format()
                                                                                                                                • mlr3::Learner$help()
                                                                                                                                • mlr3::Learner$predict()
                                                                                                                                • diff --git a/man/mlr_learners_regr.earth.Rd b/man/mlr_learners_regr.earth.Rd index c67b0954c..9045bd861 100644 --- a/man/mlr_learners_regr.earth.Rd +++ b/man/mlr_learners_regr.earth.Rd @@ -133,6 +133,7 @@ pkopper
                                                                                                                                  Inherited methods
                                                                                                                                  • mlr3::Learner$base_learner()
                                                                                                                                  • +
                                                                                                                                  • mlr3::Learner$encapsulate()
                                                                                                                                  • mlr3::Learner$format()
                                                                                                                                  • mlr3::Learner$help()
                                                                                                                                  • mlr3::Learner$predict()
                                                                                                                                  • diff --git a/man/mlr_learners_regr.fnn.Rd b/man/mlr_learners_regr.fnn.Rd index 04d407a1c..a695034bb 100644 --- a/man/mlr_learners_regr.fnn.Rd +++ b/man/mlr_learners_regr.fnn.Rd @@ -93,6 +93,7 @@ be-marc
                                                                                                                                    Inherited methods
                                                                                                                                    • mlr3::Learner$base_learner()
                                                                                                                                    • +
                                                                                                                                    • mlr3::Learner$encapsulate()
                                                                                                                                    • mlr3::Learner$format()
                                                                                                                                    • mlr3::Learner$help()
                                                                                                                                    • mlr3::Learner$predict()
                                                                                                                                    • diff --git a/man/mlr_learners_regr.gam.Rd b/man/mlr_learners_regr.gam.Rd index 86757427c..33b20c8d7 100644 --- a/man/mlr_learners_regr.gam.Rd +++ b/man/mlr_learners_regr.gam.Rd @@ -80,13 +80,14 @@ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{ } \examples{ - +\dontshow{if (requireNamespace("mgcv", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} # simple example t = mlr3::tsk("mtcars") l = mlr3::lrn("regr.gam") l$param_set$values$formula = mpg ~ cyl + am + s(disp) + s(hp) l$train(t) l$model +\dontshow{\}) # examplesIf} } \references{ Hastie, J T, Tibshirani, J R (2017). @@ -113,6 +114,7 @@ JazzyPierrot
                                                                                                                                      Inherited methods
                                                                                                                                      • mlr3::Learner$base_learner()
                                                                                                                                      • +
                                                                                                                                      • mlr3::Learner$encapsulate()
                                                                                                                                      • mlr3::Learner$format()
                                                                                                                                      • mlr3::Learner$help()
                                                                                                                                      • mlr3::Learner$predict()
                                                                                                                                      • diff --git a/man/mlr_learners_regr.gamboost.Rd b/man/mlr_learners_regr.gamboost.Rd index 68135ae19..835a23c0a 100644 --- a/man/mlr_learners_regr.gamboost.Rd +++ b/man/mlr_learners_regr.gamboost.Rd @@ -47,8 +47,9 @@ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{ } \examples{ +# Define the Learner learner = lrn("regr.gamboost", baselearner = "bols") -learner +print(learner) } \references{ BĂĽhlmann, Peter, Yu, Bin (2003). @@ -83,6 +84,7 @@ be-marc
                                                                                                                                        Inherited methods
                                                                                                                                        • mlr3::Learner$base_learner()
                                                                                                                                        • +
                                                                                                                                        • mlr3::Learner$encapsulate()
                                                                                                                                        • mlr3::Learner$format()
                                                                                                                                        • mlr3::Learner$help()
                                                                                                                                        • mlr3::Learner$predict()
                                                                                                                                        • diff --git a/man/mlr_learners_regr.gaussian_processes.Rd b/man/mlr_learners_regr.gaussian_processes.Rd index 88b40c5ad..f74d98287 100644 --- a/man/mlr_learners_regr.gaussian_processes.Rd +++ b/man/mlr_learners_regr.gaussian_processes.Rd @@ -6,7 +6,7 @@ \title{Regression Gaussian Processes Learner From Weka} \description{ Gaussian Processes. -Calls \code{\link[RWeka:make_Weka_classifier]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. +Calls \code{\link[RWeka:Weka_interfaces]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. } \section{Custom mlr3 parameters}{ @@ -144,6 +144,7 @@ damirpolat
                                                                                                                                          Inherited methods
                                                                                                                                          • mlr3::Learner$base_learner()
                                                                                                                                          • +
                                                                                                                                          • mlr3::Learner$encapsulate()
                                                                                                                                          • mlr3::Learner$format()
                                                                                                                                          • mlr3::Learner$help()
                                                                                                                                          • mlr3::Learner$predict()
                                                                                                                                          • diff --git a/man/mlr_learners_regr.gausspr.Rd b/man/mlr_learners_regr.gausspr.Rd index fa01f4a23..453e26021 100644 --- a/man/mlr_learners_regr.gausspr.Rd +++ b/man/mlr_learners_regr.gausspr.Rd @@ -107,6 +107,7 @@ RaphaelS1
                                                                                                                                            Inherited methods
                                                                                                                                            • mlr3::Learner$base_learner()
                                                                                                                                            • +
                                                                                                                                            • mlr3::Learner$encapsulate()
                                                                                                                                            • mlr3::Learner$format()
                                                                                                                                            • mlr3::Learner$help()
                                                                                                                                            • mlr3::Learner$predict()
                                                                                                                                            • diff --git a/man/mlr_learners_regr.gbm.Rd b/man/mlr_learners_regr.gbm.Rd index 0ddd92a18..e71937d85 100644 --- a/man/mlr_learners_regr.gbm.Rd +++ b/man/mlr_learners_regr.gbm.Rd @@ -104,6 +104,7 @@ be-marc
                                                                                                                                              Inherited methods
                                                                                                                                              • mlr3::Learner$base_learner()
                                                                                                                                              • +
                                                                                                                                              • mlr3::Learner$encapsulate()
                                                                                                                                              • mlr3::Learner$format()
                                                                                                                                              • mlr3::Learner$help()
                                                                                                                                              • mlr3::Learner$predict()
                                                                                                                                              • diff --git a/man/mlr_learners_regr.glm.Rd b/man/mlr_learners_regr.glm.Rd index e1b6c6586..1782d3744 100644 --- a/man/mlr_learners_regr.glm.Rd +++ b/man/mlr_learners_regr.glm.Rd @@ -119,6 +119,7 @@ salauer
                                                                                                                                                Inherited methods
                                                                                                                                                • mlr3::Learner$base_learner()
                                                                                                                                                • +
                                                                                                                                                • mlr3::Learner$encapsulate()
                                                                                                                                                • mlr3::Learner$format()
                                                                                                                                                • mlr3::Learner$help()
                                                                                                                                                • mlr3::Learner$predict()
                                                                                                                                                • diff --git a/man/mlr_learners_regr.glmboost.Rd b/man/mlr_learners_regr.glmboost.Rd index e8e336c14..173b58e3b 100644 --- a/man/mlr_learners_regr.glmboost.Rd +++ b/man/mlr_learners_regr.glmboost.Rd @@ -104,6 +104,7 @@ be-marc
                                                                                                                                                  Inherited methods
                                                                                                                                                  • mlr3::Learner$base_learner()
                                                                                                                                                  • +
                                                                                                                                                  • mlr3::Learner$encapsulate()
                                                                                                                                                  • mlr3::Learner$format()
                                                                                                                                                  • mlr3::Learner$help()
                                                                                                                                                  • mlr3::Learner$predict()
                                                                                                                                                  • diff --git a/man/mlr_learners_regr.kstar.Rd b/man/mlr_learners_regr.kstar.Rd index 8094e7bce..23ab5e070 100644 --- a/man/mlr_learners_regr.kstar.Rd +++ b/man/mlr_learners_regr.kstar.Rd @@ -7,7 +7,7 @@ \description{ Instance-based regressor which differs from other instance-based learners in that it uses an entropy-based distance function. -Calls \code{\link[RWeka:make_Weka_classifier]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. +Calls \code{\link[RWeka:Weka_interfaces]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. } \section{Custom mlr3 parameters}{ @@ -125,6 +125,7 @@ damirpolat
                                                                                                                                                    Inherited methods
                                                                                                                                                    • mlr3::Learner$base_learner()
                                                                                                                                                    • +
                                                                                                                                                    • mlr3::Learner$encapsulate()
                                                                                                                                                    • mlr3::Learner$format()
                                                                                                                                                    • mlr3::Learner$help()
                                                                                                                                                    • mlr3::Learner$predict()
                                                                                                                                                    • diff --git a/man/mlr_learners_regr.ksvm.Rd b/man/mlr_learners_regr.ksvm.Rd index 2d1995683..d7f884455 100644 --- a/man/mlr_learners_regr.ksvm.Rd +++ b/man/mlr_learners_regr.ksvm.Rd @@ -106,6 +106,7 @@ mboecker
                                                                                                                                                      Inherited methods
                                                                                                                                                      • mlr3::Learner$base_learner()
                                                                                                                                                      • +
                                                                                                                                                      • mlr3::Learner$encapsulate()
                                                                                                                                                      • mlr3::Learner$format()
                                                                                                                                                      • mlr3::Learner$help()
                                                                                                                                                      • mlr3::Learner$predict()
                                                                                                                                                      • diff --git a/man/mlr_learners_regr.liblinear.Rd b/man/mlr_learners_regr.liblinear.Rd index bbbf8955d..37deb30ca 100644 --- a/man/mlr_learners_regr.liblinear.Rd +++ b/man/mlr_learners_regr.liblinear.Rd @@ -120,6 +120,7 @@ be-marc
                                                                                                                                                        Inherited methods
                                                                                                                                                        • mlr3::Learner$base_learner()
                                                                                                                                                        • +
                                                                                                                                                        • mlr3::Learner$encapsulate()
                                                                                                                                                        • mlr3::Learner$format()
                                                                                                                                                        • mlr3::Learner$help()
                                                                                                                                                        • mlr3::Learner$predict()
                                                                                                                                                        • diff --git a/man/mlr_learners_regr.lightgbm.Rd b/man/mlr_learners_regr.lightgbm.Rd index b6333fcd0..e291eb7bd 100644 --- a/man/mlr_learners_regr.lightgbm.Rd +++ b/man/mlr_learners_regr.lightgbm.Rd @@ -57,6 +57,7 @@ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{ bagging_fraction \tab numeric \tab 1 \tab \tab \eqn{[0, 1]}{[0, 1]} \cr bagging_freq \tab integer \tab 0 \tab \tab \eqn{[0, \infty)}{[0, Inf)} \cr bagging_seed \tab integer \tab 3 \tab \tab \eqn{(-\infty, \infty)}{(-Inf, Inf)} \cr + bagging_by_query \tab logical \tab FALSE \tab TRUE, FALSE \tab - \cr feature_fraction \tab numeric \tab 1 \tab \tab \eqn{[0, 1]}{[0, 1]} \cr feature_fraction_bynode \tab numeric \tab 1 \tab \tab \eqn{[0, 1]}{[0, 1]} \cr feature_fraction_seed \tab integer \tab 2 \tab \tab \eqn{(-\infty, \infty)}{(-Inf, Inf)} \cr @@ -181,7 +182,7 @@ ids = mlr3::partition(task) learner$train(task, row_ids = ids$train) print(learner$model) -print(learner$importance) +print(learner$importance()) # Make predictions for the test rows predictions = learner$predict(task, row_ids = ids$test) @@ -237,6 +238,7 @@ This parameter can be either \code{NULL}, a ratio, \code{"test"}, or \code{"pred
                                                                                                                                                          Inherited methods
                                                                                                                                                          • mlr3::Learner$base_learner()
                                                                                                                                                          • +
                                                                                                                                                          • mlr3::Learner$encapsulate()
                                                                                                                                                          • mlr3::Learner$format()
                                                                                                                                                          • mlr3::Learner$help()
                                                                                                                                                          • mlr3::Learner$predict()
                                                                                                                                                          • diff --git a/man/mlr_learners_regr.linear_regression.Rd b/man/mlr_learners_regr.linear_regression.Rd index 105ae3a19..c4bce3f19 100644 --- a/man/mlr_learners_regr.linear_regression.Rd +++ b/man/mlr_learners_regr.linear_regression.Rd @@ -7,7 +7,7 @@ \description{ Linear Regression learner that uses the Akaike criterion for model selection and is able to deal with weighted instances. -Calls \code{\link[RWeka:LinearRegression]{RWeka::LinearRegression()}} \CRANpkg{RWeka}. +Calls \code{\link[RWeka:Weka_classifier_functions]{RWeka::LinearRegression()}} \CRANpkg{RWeka}. } \section{Custom mlr3 parameters}{ @@ -131,6 +131,7 @@ damirpolat
                                                                                                                                                            Inherited methods
                                                                                                                                                            • mlr3::Learner$base_learner()
                                                                                                                                                            • +
                                                                                                                                                            • mlr3::Learner$encapsulate()
                                                                                                                                                            • mlr3::Learner$format()
                                                                                                                                                            • mlr3::Learner$help()
                                                                                                                                                            • mlr3::Learner$predict()
                                                                                                                                                            • diff --git a/man/mlr_learners_regr.lmer.Rd b/man/mlr_learners_regr.lmer.Rd index 31713e4c0..eded593a1 100644 --- a/man/mlr_learners_regr.lmer.Rd +++ b/man/mlr_learners_regr.lmer.Rd @@ -113,6 +113,7 @@ s-kganz
                                                                                                                                                              Inherited methods
                                                                                                                                                              • mlr3::Learner$base_learner()
                                                                                                                                                              • +
                                                                                                                                                              • mlr3::Learner$encapsulate()
                                                                                                                                                              • mlr3::Learner$format()
                                                                                                                                                              • mlr3::Learner$help()
                                                                                                                                                              • mlr3::Learner$predict()
                                                                                                                                                              • diff --git a/man/mlr_learners_regr.m5p.Rd b/man/mlr_learners_regr.m5p.Rd index acf29a131..c1f82392b 100644 --- a/man/mlr_learners_regr.m5p.Rd +++ b/man/mlr_learners_regr.m5p.Rd @@ -6,7 +6,7 @@ \title{Regression M5P Learner} \description{ Implements base routines for generating M5 Model trees and rules. -Calls \code{\link[RWeka:M5P]{RWeka::M5P()}} from \CRANpkg{RWeka}. +Calls \code{\link[RWeka:Weka_classifier_trees]{RWeka::M5P()}} from \CRANpkg{RWeka}. } \section{Custom mlr3 parameters}{ @@ -130,6 +130,7 @@ damirpolat
                                                                                                                                                                Inherited methods
                                                                                                                                                                • mlr3::Learner$base_learner()
                                                                                                                                                                • +
                                                                                                                                                                • mlr3::Learner$encapsulate()
                                                                                                                                                                • mlr3::Learner$format()
                                                                                                                                                                • mlr3::Learner$help()
                                                                                                                                                                • mlr3::Learner$predict()
                                                                                                                                                                • diff --git a/man/mlr_learners_regr.mars.Rd b/man/mlr_learners_regr.mars.Rd index 60a162085..492109cf8 100644 --- a/man/mlr_learners_regr.mars.Rd +++ b/man/mlr_learners_regr.mars.Rd @@ -97,6 +97,7 @@ sumny
                                                                                                                                                                  Inherited methods
                                                                                                                                                                  • mlr3::Learner$base_learner()
                                                                                                                                                                  • +
                                                                                                                                                                  • mlr3::Learner$encapsulate()
                                                                                                                                                                  • mlr3::Learner$format()
                                                                                                                                                                  • mlr3::Learner$help()
                                                                                                                                                                  • mlr3::Learner$predict()
                                                                                                                                                                  • diff --git a/man/mlr_learners_regr.mob.Rd b/man/mlr_learners_regr.mob.Rd index 70c06fcd5..8b23ab85f 100644 --- a/man/mlr_learners_regr.mob.Rd +++ b/man/mlr_learners_regr.mob.Rd @@ -66,6 +66,7 @@ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{ } \examples{ +\dontshow{if (requireNamespace("partykit", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} library(mlr3) lm_ = function(y, x, start = NULL, weights = NULL, offset = NULL, ...) { lm(y ~ 1, ...) @@ -84,6 +85,7 @@ task = tsk("mtcars") ids = partition(task) learner$train(task, row_ids = ids$train) learner$predict(task, row_ids = ids$test) +\dontshow{\}) # examplesIf} } \references{ Hothorn T, Zeileis A (2015). @@ -124,6 +126,7 @@ sumny
                                                                                                                                                                    Inherited methods
                                                                                                                                                                    • mlr3::Learner$base_learner()
                                                                                                                                                                    • +
                                                                                                                                                                    • mlr3::Learner$encapsulate()
                                                                                                                                                                    • mlr3::Learner$format()
                                                                                                                                                                    • mlr3::Learner$help()
                                                                                                                                                                    • mlr3::Learner$predict()
                                                                                                                                                                    • diff --git a/man/mlr_learners_regr.multilayer_perceptron.Rd b/man/mlr_learners_regr.multilayer_perceptron.Rd index fa3df5493..99076bf1a 100644 --- a/man/mlr_learners_regr.multilayer_perceptron.Rd +++ b/man/mlr_learners_regr.multilayer_perceptron.Rd @@ -6,7 +6,7 @@ \title{Regression MultilayerPerceptron Learner} \description{ Regressor that uses backpropagation to learn a multi-layer perceptron. -Calls \code{\link[RWeka:make_Weka_classifier]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. +Calls \code{\link[RWeka:Weka_interfaces]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. } \section{Custom mlr3 parameters}{ @@ -134,6 +134,7 @@ damirpolat
                                                                                                                                                                      Inherited methods
                                                                                                                                                                      • mlr3::Learner$base_learner()
                                                                                                                                                                      • +
                                                                                                                                                                      • mlr3::Learner$encapsulate()
                                                                                                                                                                      • mlr3::Learner$format()
                                                                                                                                                                      • mlr3::Learner$help()
                                                                                                                                                                      • mlr3::Learner$predict()
                                                                                                                                                                      • diff --git a/man/mlr_learners_regr.priority_lasso.Rd b/man/mlr_learners_regr.priority_lasso.Rd index 7ac8fed06..5727f0393 100644 --- a/man/mlr_learners_regr.priority_lasso.Rd +++ b/man/mlr_learners_regr.priority_lasso.Rd @@ -8,6 +8,14 @@ Patient outcome prediction based on multi-omics data taking practitioners’ preferences into account. Calls \code{\link[prioritylasso:prioritylasso]{prioritylasso::prioritylasso()}} from \CRANpkg{prioritylasso}. } +\section{Initial parameter values}{ + +\itemize{ +\item \code{family} is set to \code{"gaussian"} and cannot be changed +\item \code{type.measure} set to \code{"mse"} (cross-validation measure) +} +} + \section{Dictionary}{ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{lrn()}: @@ -145,6 +153,7 @@ HarutyunyanLiana
                                                                                                                                                                        Inherited methods
                                                                                                                                                                        • mlr3::Learner$base_learner()
                                                                                                                                                                        • +
                                                                                                                                                                        • mlr3::Learner$encapsulate()
                                                                                                                                                                        • mlr3::Learner$format()
                                                                                                                                                                        • mlr3::Learner$help()
                                                                                                                                                                        • mlr3::Learner$predict()
                                                                                                                                                                        • diff --git a/man/mlr_learners_regr.randomForest.Rd b/man/mlr_learners_regr.randomForest.Rd index 072a863ec..95bcd7faa 100644 --- a/man/mlr_learners_regr.randomForest.Rd +++ b/man/mlr_learners_regr.randomForest.Rd @@ -50,14 +50,13 @@ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{ } \examples{ -\dontshow{if (mlr3misc::require_namespaces(lrn("regr.randomForest")$packages, quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (requireNamespace("randomForest", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} # Define the Learner -learner = mlr3::lrn("regr.randomForest") +learner = mlr3::lrn("regr.randomForest", importance = "mse") print(learner) # Define a Task task = mlr3::tsk("mtcars") - # Create train and test set ids = mlr3::partition(task) @@ -65,7 +64,7 @@ ids = mlr3::partition(task) learner$train(task, row_ids = ids$train) print(learner$model) -print(learner$importance) +print(learner$importance()) # Make predictions for the test rows predictions = learner$predict(task, row_ids = ids$test) @@ -110,6 +109,7 @@ pat-s
                                                                                                                                                                          Inherited methods
                                                                                                                                                                          • mlr3::Learner$base_learner()
                                                                                                                                                                          • +
                                                                                                                                                                          • mlr3::Learner$encapsulate()
                                                                                                                                                                          • mlr3::Learner$format()
                                                                                                                                                                          • mlr3::Learner$help()
                                                                                                                                                                          • mlr3::Learner$predict()
                                                                                                                                                                          • diff --git a/man/mlr_learners_regr.random_forest_weka.Rd b/man/mlr_learners_regr.random_forest_weka.Rd index 9aa14637b..4f7662d73 100644 --- a/man/mlr_learners_regr.random_forest_weka.Rd +++ b/man/mlr_learners_regr.random_forest_weka.Rd @@ -6,7 +6,7 @@ \title{Regression Random Forest Learner from Weka} \description{ Class for constructing a forest of random trees. -Calls \code{\link[RWeka:make_Weka_classifier]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. +Calls \code{\link[RWeka:Weka_interfaces]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. } \section{Custom mlr3 parameters}{ @@ -154,6 +154,7 @@ damirpolat
                                                                                                                                                                            Inherited methods
                                                                                                                                                                            • mlr3::Learner$base_learner()
                                                                                                                                                                            • +
                                                                                                                                                                            • mlr3::Learner$encapsulate()
                                                                                                                                                                            • mlr3::Learner$format()
                                                                                                                                                                            • mlr3::Learner$help()
                                                                                                                                                                            • mlr3::Learner$predict()
                                                                                                                                                                            • diff --git a/man/mlr_learners_regr.random_tree.Rd b/man/mlr_learners_regr.random_tree.Rd index f5c26cbfc..354acc10b 100644 --- a/man/mlr_learners_regr.random_tree.Rd +++ b/man/mlr_learners_regr.random_tree.Rd @@ -6,7 +6,7 @@ \title{Regression Random Tree Learner} \description{ Tree that considers K randomly chosen attributes at each node. -Calls \code{\link[RWeka:make_Weka_classifier]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. +Calls \code{\link[RWeka:Weka_interfaces]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. } \section{Custom mlr3 parameters}{ @@ -124,6 +124,7 @@ damirpolat
                                                                                                                                                                              Inherited methods
                                                                                                                                                                              • mlr3::Learner$base_learner()
                                                                                                                                                                              • +
                                                                                                                                                                              • mlr3::Learner$encapsulate()
                                                                                                                                                                              • mlr3::Learner$format()
                                                                                                                                                                              • mlr3::Learner$help()
                                                                                                                                                                              • mlr3::Learner$predict()
                                                                                                                                                                              • diff --git a/man/mlr_learners_regr.reptree.Rd b/man/mlr_learners_regr.reptree.Rd index 7e95c4720..752cbc54f 100644 --- a/man/mlr_learners_regr.reptree.Rd +++ b/man/mlr_learners_regr.reptree.Rd @@ -6,7 +6,7 @@ \title{Regression Decision Tree Learner} \description{ Fast decision tree learner. -Calls \code{\link[RWeka:make_Weka_classifier]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. +Calls \code{\link[RWeka:Weka_interfaces]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. } \section{Custom mlr3 parameters}{ @@ -124,6 +124,7 @@ damirpolat
                                                                                                                                                                                Inherited methods
                                                                                                                                                                                • mlr3::Learner$base_learner()
                                                                                                                                                                                • +
                                                                                                                                                                                • mlr3::Learner$encapsulate()
                                                                                                                                                                                • mlr3::Learner$format()
                                                                                                                                                                                • mlr3::Learner$help()
                                                                                                                                                                                • mlr3::Learner$predict()
                                                                                                                                                                                • diff --git a/man/mlr_learners_regr.rfsrc.Rd b/man/mlr_learners_regr.rfsrc.Rd index c633f8595..d311598c2 100644 --- a/man/mlr_learners_regr.rfsrc.Rd +++ b/man/mlr_learners_regr.rfsrc.Rd @@ -29,7 +29,7 @@ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{ \section{Parameters}{ \tabular{lllll}{ Id \tab Type \tab Default \tab Levels \tab Range \cr - ntree \tab integer \tab 1000 \tab \tab \eqn{[1, \infty)}{[1, Inf)} \cr + ntree \tab integer \tab 500 \tab \tab \eqn{[1, \infty)}{[1, Inf)} \cr mtry \tab integer \tab - \tab \tab \eqn{[1, \infty)}{[1, Inf)} \cr mtry.ratio \tab numeric \tab - \tab \tab \eqn{[0, 1]}{[0, 1]} \cr nodesize \tab integer \tab 15 \tab \tab \eqn{[1, \infty)}{[1, Inf)} \cr @@ -72,32 +72,25 @@ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{ \section{Custom mlr3 parameters}{ \itemize{ -\item \code{mtry}: -\itemize{ -\item This hyperparameter can alternatively be set via the added hyperparameter \code{mtry.ratio} -as \code{mtry = max(ceiling(mtry.ratio * n_features), 1)}. +\item \code{mtry}: This hyperparameter can alternatively be set via the added +hyperparameter \code{mtry.ratio} as \code{mtry = max(ceiling(mtry.ratio * n_features), 1)}. Note that \code{mtry} and \code{mtry.ratio} are mutually exclusive. -} -\item \code{sampsize}: -\itemize{ -\item This hyperparameter can alternatively be set via the added hyperparameter \code{sampsize.ratio} -as \code{sampsize = max(ceiling(sampsize.ratio * n_obs), 1)}. +\item \code{sampsize}: This hyperparameter can alternatively be set via the added +hyperparameter \code{sampsize.ratio} as \code{sampsize = max(ceiling(sampsize.ratio * n_obs), 1)}. Note that \code{sampsize} and \code{sampsize.ratio} are mutually exclusive. -} -\item \code{cores}: -This value is set as the option \code{rf.cores} during training and is set to 1 by default. +\item \code{cores}: This value is set as the option \code{rf.cores} during training and is +set to 1 by default. } } \examples{ -\dontshow{if (mlr3misc::require_namespaces(lrn("regr.rfsrc")$packages, quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (requireNamespace("randomForestSRC", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} # Define the Learner -learner = mlr3::lrn("regr.rfsrc") +learner = mlr3::lrn("regr.rfsrc", importance = "TRUE") print(learner) # Define a Task task = mlr3::tsk("mtcars") - # Create train and test set ids = mlr3::partition(task) @@ -105,7 +98,7 @@ ids = mlr3::partition(task) learner$train(task, row_ids = ids$train) print(learner$model) -print(learner$importance) +print(learner$importance()) # Make predictions for the test rows predictions = learner$predict(task, row_ids = ids$test) @@ -151,6 +144,7 @@ RaphaelS1
                                                                                                                                                                                  Inherited methods
                                                                                                                                                                                  • mlr3::Learner$base_learner()
                                                                                                                                                                                  • +
                                                                                                                                                                                  • mlr3::Learner$encapsulate()
                                                                                                                                                                                  • mlr3::Learner$format()
                                                                                                                                                                                  • mlr3::Learner$help()
                                                                                                                                                                                  • mlr3::Learner$predict()
                                                                                                                                                                                  • diff --git a/man/mlr_learners_regr.rpf.Rd b/man/mlr_learners_regr.rpf.Rd index 5d63933e0..57abb3ecb 100644 --- a/man/mlr_learners_regr.rpf.Rd +++ b/man/mlr_learners_regr.rpf.Rd @@ -125,6 +125,7 @@ jemus42
                                                                                                                                                                                    Inherited methods
                                                                                                                                                                                    • mlr3::Learner$base_learner()
                                                                                                                                                                                    • +
                                                                                                                                                                                    • mlr3::Learner$encapsulate()
                                                                                                                                                                                    • mlr3::Learner$format()
                                                                                                                                                                                    • mlr3::Learner$help()
                                                                                                                                                                                    • mlr3::Learner$predict()
                                                                                                                                                                                    • diff --git a/man/mlr_learners_regr.rsm.Rd b/man/mlr_learners_regr.rsm.Rd index ab8b003bb..e9878b831 100644 --- a/man/mlr_learners_regr.rsm.Rd +++ b/man/mlr_learners_regr.rsm.Rd @@ -103,6 +103,7 @@ sebffischer
                                                                                                                                                                                      Inherited methods
                                                                                                                                                                                      • mlr3::Learner$base_learner()
                                                                                                                                                                                      • +
                                                                                                                                                                                      • mlr3::Learner$encapsulate()
                                                                                                                                                                                      • mlr3::Learner$format()
                                                                                                                                                                                      • mlr3::Learner$help()
                                                                                                                                                                                      • mlr3::Learner$predict()
                                                                                                                                                                                      • diff --git a/man/mlr_learners_regr.rvm.Rd b/man/mlr_learners_regr.rvm.Rd index 082749530..f1299ca2d 100644 --- a/man/mlr_learners_regr.rvm.Rd +++ b/man/mlr_learners_regr.rvm.Rd @@ -113,6 +113,7 @@ RaphaelS1
                                                                                                                                                                                        Inherited methods
                                                                                                                                                                                        • mlr3::Learner$base_learner()
                                                                                                                                                                                        • +
                                                                                                                                                                                        • mlr3::Learner$encapsulate()
                                                                                                                                                                                        • mlr3::Learner$format()
                                                                                                                                                                                        • mlr3::Learner$help()
                                                                                                                                                                                        • mlr3::Learner$predict()
                                                                                                                                                                                        • diff --git a/man/mlr_learners_regr.sgd.Rd b/man/mlr_learners_regr.sgd.Rd index d9ef4b0a0..48a0bb3aa 100644 --- a/man/mlr_learners_regr.sgd.Rd +++ b/man/mlr_learners_regr.sgd.Rd @@ -6,7 +6,7 @@ \title{Regression Stochastic Gradient Descent Learner} \description{ Stochastic Gradient Descent for learning various linear models. -Calls \code{\link[RWeka:make_Weka_classifier]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. +Calls \code{\link[RWeka:Weka_interfaces]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. } \section{Initial parameter values}{ @@ -137,6 +137,7 @@ damirpolat
                                                                                                                                                                                          Inherited methods
                                                                                                                                                                                          • mlr3::Learner$base_learner()
                                                                                                                                                                                          • +
                                                                                                                                                                                          • mlr3::Learner$encapsulate()
                                                                                                                                                                                          • mlr3::Learner$format()
                                                                                                                                                                                          • mlr3::Learner$help()
                                                                                                                                                                                          • mlr3::Learner$predict()
                                                                                                                                                                                          • diff --git a/man/mlr_learners_regr.simple_linear_regression.Rd b/man/mlr_learners_regr.simple_linear_regression.Rd index d8cee7f24..1860b7f77 100644 --- a/man/mlr_learners_regr.simple_linear_regression.Rd +++ b/man/mlr_learners_regr.simple_linear_regression.Rd @@ -6,7 +6,7 @@ \title{Regression SimpleLinearRegression Learner from Weka} \description{ Simple linear regression model that picks the attribute that results in the lowest squared error. -Calls \code{\link[RWeka:make_Weka_classifier]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. +Calls \code{\link[RWeka:Weka_interfaces]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. } \section{Custom mlr3 parameters}{ @@ -121,6 +121,7 @@ damirpolat
                                                                                                                                                                                            Inherited methods
                                                                                                                                                                                            • mlr3::Learner$base_learner()
                                                                                                                                                                                            • +
                                                                                                                                                                                            • mlr3::Learner$encapsulate()
                                                                                                                                                                                            • mlr3::Learner$format()
                                                                                                                                                                                            • mlr3::Learner$help()
                                                                                                                                                                                            • mlr3::Learner$predict()
                                                                                                                                                                                            • diff --git a/man/mlr_learners_regr.smo_reg.Rd b/man/mlr_learners_regr.smo_reg.Rd index 269a5f091..12f62fac9 100644 --- a/man/mlr_learners_regr.smo_reg.Rd +++ b/man/mlr_learners_regr.smo_reg.Rd @@ -6,7 +6,7 @@ \title{Regression Support Vector Machine Learner} \description{ Support Vector Machine for regression. -Calls \code{\link[RWeka:make_Weka_classifier]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. +Calls \code{\link[RWeka:Weka_interfaces]{RWeka::make_Weka_classifier()}} from \CRANpkg{RWeka}. } \section{Custom mlr3 parameters}{ @@ -165,6 +165,7 @@ damirpolat
                                                                                                                                                                                              Inherited methods
                                                                                                                                                                                              • mlr3::Learner$base_learner()
                                                                                                                                                                                              • +
                                                                                                                                                                                              • mlr3::Learner$encapsulate()
                                                                                                                                                                                              • mlr3::Learner$format()
                                                                                                                                                                                              • mlr3::Learner$help()
                                                                                                                                                                                              • mlr3::Learner$predict()
                                                                                                                                                                                              • diff --git a/man/mlr_learners_surv.akritas.Rd b/man/mlr_learners_surv.akritas.Rd index 696ac1d67..68281a023 100644 --- a/man/mlr_learners_surv.akritas.Rd +++ b/man/mlr_learners_surv.akritas.Rd @@ -8,6 +8,21 @@ Survival akritas estimator. Calls \code{\link[survivalmodels:akritas]{survivalmodels::akritas()}} from package 'survivalmodels'. } +\section{Prediction types}{ + +This learner returns two prediction types: +\enumerate{ +\item \code{distr}: a survival matrix in two dimensions, where observations are +represented in rows and time points in columns. +Calculated using the internal \code{\link[survivalmodels:predict.akritas]{survivalmodels::predict.akritas()}} function. +The survival matrix uses the unique time points from the training set. +We advise to set the parameter \code{ntime} which allows to adjust the granularity +of these time points to a reasonable number (e.g. \code{150}). +This avoids large execution times during prediction. +\item \code{crank}: the expected mortality using \code{\link[survivalmodels:surv_to_risk]{survivalmodels::surv_to_risk()}}. +} +} + \section{Dictionary}{ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{lrn()}: @@ -31,7 +46,7 @@ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{ Id \tab Type \tab Default \tab Levels \tab Range \cr lambda \tab numeric \tab 0.5 \tab \tab \eqn{[0, 1]}{[0, 1]} \cr reverse \tab logical \tab FALSE \tab TRUE, FALSE \tab - \cr - ntime \tab numeric \tab 150 \tab \tab \eqn{[1, \infty)}{[1, Inf)} \cr + ntime \tab integer \tab NULL \tab \tab \eqn{[1, \infty)}{[1, Inf)} \cr round_time \tab integer \tab 2 \tab \tab \eqn{[0, \infty)}{[0, Inf)} \cr } } @@ -100,6 +115,7 @@ RaphaelS1
                                                                                                                                                                                                Inherited methods
                                                                                                                                                                                                • mlr3::Learner$base_learner()
                                                                                                                                                                                                • +
                                                                                                                                                                                                • mlr3::Learner$encapsulate()
                                                                                                                                                                                                • mlr3::Learner$format()
                                                                                                                                                                                                • mlr3::Learner$help()
                                                                                                                                                                                                • mlr3::Learner$predict()
                                                                                                                                                                                                • diff --git a/man/mlr_learners_surv.aorsf.Rd b/man/mlr_learners_surv.aorsf.Rd index 16d410a9b..8d8753981 100644 --- a/man/mlr_learners_surv.aorsf.Rd +++ b/man/mlr_learners_surv.aorsf.Rd @@ -11,16 +11,36 @@ Note that although the learner has the property \code{"missing"} and it can in principle deal with missing values, the behaviour has to be configured using the parameter \code{na_action}. } -\details{ +\section{Initial parameter values}{ + +\itemize{ +\item \code{n_thread}: This parameter is initialized to 1 (default is 0) to avoid conflicts with the mlr3 parallelization. +} + + +\itemize{ +\item \code{mtry}: +\itemize{ +\item This hyperparameter can alternatively be set via the added hyperparameter \code{mtry_ratio} +as \code{mtry = max(ceiling(mtry_ratio * n_features), 1)}. +Note that \code{mtry} and \code{mtry_ratio} are mutually exclusive. +} +} +} + +\section{Prediction types}{ + This learner returns three prediction types: \enumerate{ \item \code{distr}: a survival matrix in two dimensions, where observations are represented in rows and (unique event) time points in columns. +Calculated using the internal \code{predict.ObliqueForest()} function. \item \code{response}: the restricted mean survival time of each test observation, derived from the survival matrix prediction (\code{distr}). -\item \code{crank}: the expected mortality using \link[mlr3proba:dot-surv_return]{mlr3proba::.surv_return}. +\item \code{crank}: the expected mortality using \code{\link[mlr3proba:dot-surv_return]{mlr3proba::.surv_return()}}. } } + \section{Dictionary}{ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{lrn()}: @@ -80,18 +100,6 @@ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{ } } -\section{Initial parameter values}{ - -\itemize{ -\item \code{mtry}: -\itemize{ -\item This hyperparameter can alternatively be set via the added hyperparameter \code{mtry_ratio} -as \code{mtry = max(ceiling(mtry_ratio * n_features), 1)}. -Note that \code{mtry} and \code{mtry_ratio} are mutually exclusive. -} -} -} - \examples{ \dontshow{if (mlr3misc::require_namespaces(lrn("surv.aorsf")$packages, quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} # Define the Learner @@ -108,7 +116,7 @@ ids = mlr3::partition(task) learner$train(task, row_ids = ids$train) print(learner$model) -print(learner$importance) +print(learner$importance()) # Make predictions for the test rows predictions = learner$predict(task, row_ids = ids$test) @@ -158,6 +166,7 @@ bcjaeger
                                                                                                                                                                                                  Inherited methods
                                                                                                                                                                                                  • mlr3::Learner$base_learner()
                                                                                                                                                                                                  • +
                                                                                                                                                                                                  • mlr3::Learner$encapsulate()
                                                                                                                                                                                                  • mlr3::Learner$format()
                                                                                                                                                                                                  • mlr3::Learner$help()
                                                                                                                                                                                                  • mlr3::Learner$predict()
                                                                                                                                                                                                  • diff --git a/man/mlr_learners_surv.bart.Rd b/man/mlr_learners_surv.bart.Rd index fb3adf745..1547c9f3c 100644 --- a/man/mlr_learners_surv.bart.Rd +++ b/man/mlr_learners_surv.bart.Rd @@ -6,20 +6,23 @@ \title{Survival Bayesian Additive Regression Trees Learner} \description{ Fits a Bayesian Additive Regression Trees (BART) learner to right-censored -survival data. Calls \code{\link[BART:mc.surv.bart]{BART::mc.surv.bart()}} from \CRANpkg{BART}. +survival data. Calls \code{\link[BART:surv.bart]{BART::mc.surv.bart()}} from \CRANpkg{BART}. } -\details{ -Two types of prediction are returned for this learner: +\section{Prediction types}{ + +This learner returns two prediction types: \enumerate{ \item \code{distr}: a 3d survival array with observations as 1st dimension, time points as 2nd and the posterior draws as 3rd dimension. -\item \code{crank}: the expected mortality using \link[mlr3proba:dot-surv_return]{mlr3proba::.surv_return}. The parameter +Calculated using the internal \code{predict.survbart()} function. +\item \code{crank}: the expected mortality using \code{\link[mlr3proba:dot-surv_return]{mlr3proba::.surv_return()}}. The parameter \code{which.curve} decides which posterior draw (3rd dimension) will be used for the calculation of the expected mortality. Note that the median posterior is by default used for the calculation of survival measures that require a \code{distr} prediction, see more info on \link[mlr3proba:PredictionSurv]{PredictionSurv}. } } + \section{Initial parameter values}{ \itemize{ @@ -139,6 +142,7 @@ bblodfon
                                                                                                                                                                                                    Inherited methods
                                                                                                                                                                                                    • mlr3::Learner$base_learner()
                                                                                                                                                                                                    • +
                                                                                                                                                                                                    • mlr3::Learner$encapsulate()
                                                                                                                                                                                                    • mlr3::Learner$format()
                                                                                                                                                                                                    • mlr3::Learner$help()
                                                                                                                                                                                                    • mlr3::Learner$predict()
                                                                                                                                                                                                    • diff --git a/man/mlr_learners_surv.blackboost.Rd b/man/mlr_learners_surv.blackboost.Rd index e7c1c0ce6..5f37d1248 100644 --- a/man/mlr_learners_surv.blackboost.Rd +++ b/man/mlr_learners_surv.blackboost.Rd @@ -11,6 +11,25 @@ Calls \code{\link[mboost:blackboost]{mboost::blackboost()}} from \CRANpkg{mboost \details{ \code{distr} prediction made by \code{\link[mboost:survFit]{mboost::survFit()}}. } +\section{Prediction types}{ + +This learner returns two to three prediction types: +\enumerate{ +\item \code{lp}: a vector containing the linear predictors (relative risk scores), +where each score corresponds to a specific test observation. +Calculated using \code{\link[mboost:methods]{mboost::predict.blackboost()}}. +If the \code{family} parameter is not \code{"coxph"}, \code{-lp} is returned, since non-coxph +families represent AFT-style distributions where lower \code{lp} values indicate higher risk. +\item \code{crank}: same as \code{lp}. +\item \code{distr}: a survival matrix in two dimensions, where observations are +represented in rows and time points in columns. +Calculated using \code{\link[mboost:survFit]{mboost::survFit()}}. +This prediction type is present only when the \code{family} distribution parameter +is equal to \code{"coxph"} (default). +By default the Breslow estimator is used for computing the baseline hazard. +} +} + \section{Dictionary}{ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{lrn()}: @@ -134,6 +153,7 @@ RaphaelS1
                                                                                                                                                                                                      Inherited methods
                                                                                                                                                                                                      • mlr3::Learner$base_learner()
                                                                                                                                                                                                      • +
                                                                                                                                                                                                      • mlr3::Learner$encapsulate()
                                                                                                                                                                                                      • mlr3::Learner$format()
                                                                                                                                                                                                      • mlr3::Learner$help()
                                                                                                                                                                                                      • mlr3::Learner$predict()
                                                                                                                                                                                                      • diff --git a/man/mlr_learners_surv.cforest.Rd b/man/mlr_learners_surv.cforest.Rd index fa56af8c8..1a21711d3 100644 --- a/man/mlr_learners_surv.cforest.Rd +++ b/man/mlr_learners_surv.cforest.Rd @@ -8,6 +8,17 @@ A random forest based on conditional inference trees (\link[partykit:ctree]{ctree}). Calls \code{\link[partykit:cforest]{partykit::cforest()}} from \CRANpkg{partykit}. } +\section{Prediction types}{ + +This learner returns two prediction types: +\enumerate{ +\item \code{distr}: a survival matrix in two dimensions, where observations are +represented in rows and time points in columns. +Calculated using the internal \code{\link[partykit:cforest]{partykit::predict.cforest()}} function. +\item \code{crank}: the expected mortality using \code{\link[mlr3proba:dot-surv_return]{mlr3proba::.surv_return()}}. +} +} + \section{Dictionary}{ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{lrn()}: @@ -78,6 +89,14 @@ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{ } } +\section{Initial parameter values}{ + +\itemize{ +\item \code{cores}: This parameter is initialized to 1 (default is \code{NULL}) to avoid +threading conflicts with \CRANpkg{future}. +} +} + \section{Custom mlr3 parameters}{ \itemize{ @@ -138,6 +157,7 @@ RaphaelS1
                                                                                                                                                                                                        Inherited methods
                                                                                                                                                                                                        • mlr3::Learner$base_learner()
                                                                                                                                                                                                        • +
                                                                                                                                                                                                        • mlr3::Learner$encapsulate()
                                                                                                                                                                                                        • mlr3::Learner$format()
                                                                                                                                                                                                        • mlr3::Learner$help()
                                                                                                                                                                                                        • mlr3::Learner$predict()
                                                                                                                                                                                                        • diff --git a/man/mlr_learners_surv.coxboost.Rd b/man/mlr_learners_surv.coxboost.Rd index 9567523d5..031b13767 100644 --- a/man/mlr_learners_surv.coxboost.Rd +++ b/man/mlr_learners_surv.coxboost.Rd @@ -14,18 +14,20 @@ cross-validation of boosting step number, respectively. Tuning using the interna \link{LearnerSurvCVCoxboost} may be more efficient when tuning \code{stepno} only. However, for tuning multiple hyperparameters, \CRANpkg{mlr3tuning} and \link{LearnerSurvCoxboost} will likely give better results. +} +\section{Prediction types}{ -Three prediction types are returned for this learner, using the internal -\code{predict.CoxBoost()} function: +This learner returns three prediction types, using the internal \code{predict.CoxBoost()} function: \enumerate{ -\item \code{lp}: a vector of linear predictors (relative risk scores), one per -observation. +\item \code{lp}: a vector containing the linear predictors (relative risk scores), +where each score corresponds to a specific test observation. \item \code{crank}: same as \code{lp}. \item \code{distr}: a 2d survival matrix, with observations as rows and time points -as columns. The internal transformation uses the Breslow estimator to compose -the survival distributions from the \code{lp} predictions. +as columns. The internal transformation uses the Breslow estimator to compute +the baseline hazard and compose the survival distributions from the \code{lp} predictions. } } + \section{Dictionary}{ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{lrn()}: @@ -128,6 +130,7 @@ RaphaelS1
                                                                                                                                                                                                          Inherited methods
                                                                                                                                                                                                          • mlr3::Learner$base_learner()
                                                                                                                                                                                                          • +
                                                                                                                                                                                                          • mlr3::Learner$encapsulate()
                                                                                                                                                                                                          • mlr3::Learner$format()
                                                                                                                                                                                                          • mlr3::Learner$help()
                                                                                                                                                                                                          • mlr3::Learner$predict()
                                                                                                                                                                                                          • diff --git a/man/mlr_learners_surv.coxtime.Rd b/man/mlr_learners_surv.coxtime.Rd index 977271f16..a5a73a2e0 100644 --- a/man/mlr_learners_surv.coxtime.Rd +++ b/man/mlr_learners_surv.coxtime.Rd @@ -8,6 +8,17 @@ Cox-Time survival model. Calls \code{\link[survivalmodels:coxtime]{survivalmodels::coxtime()}} from package 'survivalmodels'. } +\section{Prediction types}{ + +This learner returns two prediction types: +\enumerate{ +\item \code{distr}: a survival matrix in two dimensions, where observations are +represented in rows and time points in columns. +Calculated using the internal \code{\link[survivalmodels:predict.pycox]{survivalmodels::predict.pycox()}} function. +\item \code{crank}: the expected mortality using \code{\link[survivalmodels:surv_to_risk]{survivalmodels::surv_to_risk()}}. +} +} + \section{Dictionary}{ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{lrn()}: @@ -112,6 +123,7 @@ RaphaelS1
                                                                                                                                                                                                            Inherited methods
                                                                                                                                                                                                            • mlr3::Learner$base_learner()
                                                                                                                                                                                                            • +
                                                                                                                                                                                                            • mlr3::Learner$encapsulate()
                                                                                                                                                                                                            • mlr3::Learner$format()
                                                                                                                                                                                                            • mlr3::Learner$help()
                                                                                                                                                                                                            • mlr3::Learner$predict()
                                                                                                                                                                                                            • diff --git a/man/mlr_learners_surv.ctree.Rd b/man/mlr_learners_surv.ctree.Rd index 3e0c783ba..deb8f0721 100644 --- a/man/mlr_learners_surv.ctree.Rd +++ b/man/mlr_learners_surv.ctree.Rd @@ -8,6 +8,17 @@ Survival Partition Tree where a significance test is used to determine the univariate splits. Calls \code{\link[partykit:ctree]{partykit::ctree()}} from \CRANpkg{partykit}. } +\section{Prediction types}{ + +This learner returns two prediction types: +\enumerate{ +\item \code{distr}: a survival matrix in two dimensions, where observations are +represented in rows and time points in columns. +Calculated using the internal \code{\link[partykit:party-predict]{partykit::predict.party()}} function. +\item \code{crank}: the expected mortality using \code{\link[mlr3proba:dot-surv_return]{mlr3proba::.surv_return()}}. +} +} + \section{Dictionary}{ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{lrn()}: @@ -134,6 +145,7 @@ adibender
                                                                                                                                                                                                              Inherited methods
                                                                                                                                                                                                              • mlr3::Learner$base_learner()
                                                                                                                                                                                                              • +
                                                                                                                                                                                                              • mlr3::Learner$encapsulate()
                                                                                                                                                                                                              • mlr3::Learner$format()
                                                                                                                                                                                                              • mlr3::Learner$help()
                                                                                                                                                                                                              • mlr3::Learner$predict()
                                                                                                                                                                                                              • diff --git a/man/mlr_learners_surv.cv_coxboost.Rd b/man/mlr_learners_surv.cv_coxboost.Rd index cfdb4228b..e6ed92650 100644 --- a/man/mlr_learners_surv.cv_coxboost.Rd +++ b/man/mlr_learners_surv.cv_coxboost.Rd @@ -5,7 +5,7 @@ \alias{LearnerSurvCVCoxboost} \title{Survival Cox Model with Cross-Validation Likelihood Based Boosting Learner} \description{ -Fits a survival Cox model using likelihood based boosting and interal cross-validation for the +Fits a survival Cox model using likelihood based boosting and internal cross-validation for the number of steps. Calls \code{\link[CoxBoost:CoxBoost]{CoxBoost::CoxBoost()}} or \code{\link[CoxBoost:cv.CoxBoost]{CoxBoost::cv.CoxBoost()}} from package 'CoxBoost'. } @@ -18,17 +18,6 @@ results. If \code{penalty == "optimCoxBoostPenalty"} then \link[CoxBoost:optimCoxBoostPenalty]{CoxBoost::optimCoxBoostPenalty} is used to determine the penalty value to be used in \link[CoxBoost:cv.CoxBoost]{CoxBoost::cv.CoxBoost}. - -Three prediction types are returned for this learner, using the internal -\code{predict.CoxBoost()} function: -\enumerate{ -\item \code{lp}: a vector of linear predictors (relative risk scores), one per -observation. -\item \code{crank}: same as \code{lp}. -\item \code{distr}: a 2d survival matrix, with observations as rows and time points -as columns. The internal transformation uses the Breslow estimator to compose -the survival distributions from the \code{lp} predictions. -} } \section{Dictionary}{ @@ -80,6 +69,19 @@ The package 'CoxBoost' is not on CRAN and has to be installed from GitHub using \code{remotes::install_github("binderh/CoxBoost")}. } +\section{Prediction types}{ + +This learner returns three prediction types, using the internal \code{predict.CoxBoost()} function: +\enumerate{ +\item \code{lp}: a vector containing the linear predictors (relative risk scores), +where each score corresponds to a specific test observation. +\item \code{crank}: same as \code{lp}. +\item \code{distr}: a 2d survival matrix, with observations as rows and time points +as columns. The internal transformation uses the Breslow estimator to compute +the baseline hazard and compose the survival distributions from the \code{lp} predictions. +} +} + \examples{ \dontshow{if (mlr3misc::require_namespaces(c("coin", "sandwich", "partykit"), quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} task = tsk("rats") @@ -124,6 +126,7 @@ RaphaelS1
                                                                                                                                                                                                                Inherited methods
                                                                                                                                                                                                                • mlr3::Learner$base_learner()
                                                                                                                                                                                                                • +
                                                                                                                                                                                                                • mlr3::Learner$encapsulate()
                                                                                                                                                                                                                • mlr3::Learner$format()
                                                                                                                                                                                                                • mlr3::Learner$help()
                                                                                                                                                                                                                • mlr3::Learner$predict()
                                                                                                                                                                                                                • diff --git a/man/mlr_learners_surv.cv_glmnet.Rd b/man/mlr_learners_surv.cv_glmnet.Rd index 392d2e8af..e77cce8bf 100644 --- a/man/mlr_learners_surv.cv_glmnet.Rd +++ b/man/mlr_learners_surv.cv_glmnet.Rd @@ -8,24 +8,27 @@ Generalized linear models with elastic net regularization. Calls \code{\link[glmnet:cv.glmnet]{glmnet::cv.glmnet()}} from package \CRANpkg{glmnet}. } -\details{ -This learner returns two prediction types: +\section{Initial parameter values}{ + +\itemize{ +\item \code{family} is set to \code{"cox"} and cannot be changed. +} +} + +\section{Prediction types}{ + +This learner returns three prediction types: \enumerate{ -\item \code{lp}: a vector of linear predictors (relative risk scores), one per -observation. +\item \code{lp}: a vector containing the linear predictors (relative risk scores), +where each score corresponds to a specific test observation. Calculated using \code{\link[glmnet:predict.cv.glmnet]{glmnet::predict.cv.glmnet()}}. +\item \code{crank}: same as \code{lp}. \item \code{distr}: a survival matrix in two dimensions, where observations are represented in rows and time points in columns. Calculated using \code{\link[glmnet:survfit.cv.glmnet]{glmnet::survfit.cv.glmnet()}}. Parameters \code{stype} and \code{ctype} relate to how \code{lp} predictions are transformed into survival predictions and are described in \code{\link[survival:survfit.coxph]{survival::survfit.coxph()}}. -By default the Breslow estimator is used. -} -} -\section{Custom mlr3 parameters}{ - -\itemize{ -\item \code{family} is set to \code{"cox"} and cannot be changed. +By default the Breslow estimator is used for computing the baseline hazard. } } @@ -158,6 +161,7 @@ be-marc
                                                                                                                                                                                                                  Inherited methods
                                                                                                                                                                                                                  • mlr3::Learner$base_learner()
                                                                                                                                                                                                                  • +
                                                                                                                                                                                                                  • mlr3::Learner$encapsulate()
                                                                                                                                                                                                                  • mlr3::Learner$format()
                                                                                                                                                                                                                  • mlr3::Learner$help()
                                                                                                                                                                                                                  • mlr3::Learner$predict()
                                                                                                                                                                                                                  • diff --git a/man/mlr_learners_surv.deephit.Rd b/man/mlr_learners_surv.deephit.Rd index e550d7a32..0ca211d04 100644 --- a/man/mlr_learners_surv.deephit.Rd +++ b/man/mlr_learners_surv.deephit.Rd @@ -14,6 +14,17 @@ Custom nets can be used in this learner either using the The number of output channels depends on the number of discretised time-points, i.e. the parameters \code{cuts} or \code{cutpoints}. } +\section{Prediction types}{ + +This learner returns two prediction types: +\enumerate{ +\item \code{distr}: a survival matrix in two dimensions, where observations are +represented in rows and time points in columns. +Calculated using the internal \code{\link[survivalmodels:predict.pycox]{survivalmodels::predict.pycox()}} function. +\item \code{crank}: the expected mortality using \code{\link[survivalmodels:surv_to_risk]{survivalmodels::surv_to_risk()}}. +} +} + \section{Dictionary}{ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{lrn()}: @@ -123,6 +134,7 @@ RaphaelS1
                                                                                                                                                                                                                    Inherited methods
                                                                                                                                                                                                                    • mlr3::Learner$base_learner()
                                                                                                                                                                                                                    • +
                                                                                                                                                                                                                    • mlr3::Learner$encapsulate()
                                                                                                                                                                                                                    • mlr3::Learner$format()
                                                                                                                                                                                                                    • mlr3::Learner$help()
                                                                                                                                                                                                                    • mlr3::Learner$predict()
                                                                                                                                                                                                                    • diff --git a/man/mlr_learners_surv.deepsurv.Rd b/man/mlr_learners_surv.deepsurv.Rd index 7619249f7..606547cc3 100644 --- a/man/mlr_learners_surv.deepsurv.Rd +++ b/man/mlr_learners_surv.deepsurv.Rd @@ -6,8 +6,19 @@ \title{Survival DeepSurv Learner} \description{ DeepSurv fits a neural network based on the partial likelihood from a Cox PH. -Calls \code{\link[survivalmodels:dnnsurv]{survivalmodels::dnnsurv()}} from package 'survivalmodels'. +Calls \code{\link[survivalmodels:deepsurv]{survivalmodels::deepsurv()}} from package 'survivalmodels'. } +\section{Prediction types}{ + +This learner returns two prediction types: +\enumerate{ +\item \code{distr}: a survival matrix in two dimensions, where observations are +represented in rows and time points in columns. +Calculated using the internal \code{\link[survivalmodels:predict.pycox]{survivalmodels::predict.pycox()}} function. +\item \code{crank}: the expected mortality using \code{\link[survivalmodels:surv_to_risk]{survivalmodels::surv_to_risk()}}. +} +} + \section{Dictionary}{ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{lrn()}: @@ -107,6 +118,7 @@ RaphaelS1
                                                                                                                                                                                                                      Inherited methods
                                                                                                                                                                                                                      • mlr3::Learner$base_learner()
                                                                                                                                                                                                                      • +
                                                                                                                                                                                                                      • mlr3::Learner$encapsulate()
                                                                                                                                                                                                                      • mlr3::Learner$format()
                                                                                                                                                                                                                      • mlr3::Learner$help()
                                                                                                                                                                                                                      • mlr3::Learner$predict()
                                                                                                                                                                                                                      • diff --git a/man/mlr_learners_surv.dnnsurv.Rd b/man/mlr_learners_surv.dnnsurv.Rd index f26490d56..ca83c3804 100644 --- a/man/mlr_learners_surv.dnnsurv.Rd +++ b/man/mlr_learners_surv.dnnsurv.Rd @@ -14,6 +14,17 @@ Custom nets can be used in this learner either using the The number of output channels should be of length \code{1} and number of input channels is the number of features plus number of cuts. } +\section{Prediction types}{ + +This learner returns two prediction types: +\enumerate{ +\item \code{distr}: a survival matrix in two dimensions, where observations are +represented in rows and time points in columns. +Calculated using the internal \code{\link[survivalmodels:predict.dnnsurv]{survivalmodels::predict.dnnsurv()}} function. +\item \code{crank}: the expected mortality using \code{\link[survivalmodels:surv_to_risk]{survivalmodels::surv_to_risk()}}. +} +} + \section{Dictionary}{ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{lrn()}: @@ -132,6 +143,7 @@ RaphaelS1
                                                                                                                                                                                                                        Inherited methods
                                                                                                                                                                                                                        • mlr3::Learner$base_learner()
                                                                                                                                                                                                                        • +
                                                                                                                                                                                                                        • mlr3::Learner$encapsulate()
                                                                                                                                                                                                                        • mlr3::Learner$format()
                                                                                                                                                                                                                        • mlr3::Learner$help()
                                                                                                                                                                                                                        • mlr3::Learner$predict()
                                                                                                                                                                                                                        • diff --git a/man/mlr_learners_surv.flexible.Rd b/man/mlr_learners_surv.flexible.Rd index 9c4522a2d..64cf7cd1d 100644 --- a/man/mlr_learners_surv.flexible.Rd +++ b/man/mlr_learners_surv.flexible.Rd @@ -8,21 +8,6 @@ Flexible parametric spline learner. Calls \code{\link[flexsurv:flexsurvspline]{flexsurv::flexsurvspline()}} from \CRANpkg{flexsurv}. } -\details{ -This learner returns two prediction types: -\enumerate{ -\item \code{lp}: a vector of linear predictors (relative risk scores), for each test -observation. -Calculated using \code{\link[flexsurv:flexsurvspline]{flexsurv::flexsurvspline()}} and the estimated coefficients. -For fitted coefficients, \eqn{\beta = (\beta_0,...,\beta_P)}, -and covariates \eqn{X^T = (X_0,...,X_P)^T}, where \eqn{X_0}{X0} -is a column of \eqn{1}s, the linear predictor (\code{lp}) is \eqn{lp = \beta X}. -\item \code{distr}: a survival matrix in two dimensions, where observations are -represented in rows and time points in columns. -Calculated using \code{predict.flexsurvreg()}. -\item \code{crank}: same as \code{lp}. -} -} \section{Dictionary}{ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{lrn()}: @@ -63,6 +48,23 @@ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{ } } +\section{Prediction types}{ + +This learner returns three prediction types: +\enumerate{ +\item \code{lp}: a vector containing the linear predictors (relative risk scores), +where each score corresponds to a specific test observation. +Calculated using \code{\link[flexsurv:flexsurvspline]{flexsurv::flexsurvspline()}} and the estimated coefficients. +For fitted coefficients, \eqn{\hat{\beta} = (\hat{\beta_0},...,\hat{\beta_P})}, +and the test data covariates \eqn{X^T = (X_0,...,X_P)^T}, where \eqn{X_0}{X0} +is a column of \eqn{1}s, the linear predictor vector is \eqn{lp = \hat{\beta} X^T}. +\item \code{distr}: a survival matrix in two dimensions, where observations are +represented in rows and time points in columns. +Calculated using \code{predict.flexsurvreg()}. +\item \code{crank}: same as \code{lp}. +} +} + \section{Initial parameter values}{ \itemize{ @@ -112,6 +114,7 @@ RaphaelS1
                                                                                                                                                                                                                          Inherited methods
                                                                                                                                                                                                                          • mlr3::Learner$base_learner()
                                                                                                                                                                                                                          • +
                                                                                                                                                                                                                          • mlr3::Learner$encapsulate()
                                                                                                                                                                                                                          • mlr3::Learner$format()
                                                                                                                                                                                                                          • mlr3::Learner$help()
                                                                                                                                                                                                                          • mlr3::Learner$predict()
                                                                                                                                                                                                                          • diff --git a/man/mlr_learners_surv.gamboost.Rd b/man/mlr_learners_surv.gamboost.Rd index c32d755f3..6ea875317 100644 --- a/man/mlr_learners_surv.gamboost.Rd +++ b/man/mlr_learners_surv.gamboost.Rd @@ -8,9 +8,6 @@ Fits a generalized additive survival model using a boosting algorithm. Calls \code{\link[mboost:gamboost]{mboost::gamboost()}} from \CRANpkg{mboost}. } -\details{ -\code{distr} prediction made by \code{\link[mboost:survFit]{mboost::survFit()}}. -} \section{Dictionary}{ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{lrn()}: @@ -51,6 +48,25 @@ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{ } } +\section{Prediction types}{ + +This learner returns two to three prediction types: +\enumerate{ +\item \code{lp}: a vector containing the linear predictors (relative risk scores), +where each score corresponds to a specific test observation. +Calculated using \code{\link[mboost:methods]{mboost::predict.gamboost()}}. +If the \code{family} parameter is not \code{"coxph"}, \code{-lp} is returned, since non-coxph +families represent AFT-style distributions where lower \code{lp} values indicate higher risk. +\item \code{crank}: same as \code{lp}. +\item \code{distr}: a survival matrix in two dimensions, where observations are +represented in rows and time points in columns. +Calculated using \code{\link[mboost:survFit]{mboost::survFit()}}. +This prediction type is present only when the \code{family} distribution parameter +is equal to \code{"coxph"} (default). +By default the Breslow estimator is used for computing the baseline hazard. +} +} + \examples{ lrn("surv.gamboost") } @@ -89,6 +105,7 @@ RaphaelS1
                                                                                                                                                                                                                            Inherited methods
                                                                                                                                                                                                                            • mlr3::Learner$base_learner()
                                                                                                                                                                                                                            • +
                                                                                                                                                                                                                            • mlr3::Learner$encapsulate()
                                                                                                                                                                                                                            • mlr3::Learner$format()
                                                                                                                                                                                                                            • mlr3::Learner$help()
                                                                                                                                                                                                                            • mlr3::Learner$predict()
                                                                                                                                                                                                                            • diff --git a/man/mlr_learners_surv.gbm.Rd b/man/mlr_learners_surv.gbm.Rd index 961618987..087f01b9e 100644 --- a/man/mlr_learners_surv.gbm.Rd +++ b/man/mlr_learners_surv.gbm.Rd @@ -8,6 +8,16 @@ Gradient Boosting for Survival Analysis. Calls \code{\link[gbm:gbm]{gbm::gbm()}} from \CRANpkg{gbm}. } +\section{Prediction types}{ + +This learner returns two prediction types, using the internal \code{predict.gbm()} function: +\enumerate{ +\item \code{lp}: a vector containing the linear predictors (relative risk scores), +where each score corresponds to a specific test observation. +\item \code{crank}: same as \code{lp}. +} +} + \section{Dictionary}{ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{lrn()}: @@ -45,12 +55,12 @@ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{ } } -\section{Parameter changes}{ +\section{Initial parameter values}{ \itemize{ \item \code{distribution}: -\item Actual default: "bernoulli" -\item Adjusted default: "coxph" +\item Actual default: \code{"bernoulli"} +\item Adjusted default: \code{"coxph"} \item Reason for change: This is the only distribution available for survival. \item \code{keep.data}: \itemize{ @@ -61,9 +71,9 @@ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{ \item \code{n.cores}: \itemize{ \item Actual default: NULL -\item Adjusted default: 1 +\item Adjusted default: \code{1} \item Reason for change: Suppressing the automatic internal parallelization if -\code{cv.folds} > 0. +\code{cv.folds} > 0 and avoid threading conflicts with \CRANpkg{future}. } } } @@ -84,7 +94,7 @@ ids = mlr3::partition(task) learner$train(task, row_ids = ids$train) print(learner$model) -print(learner$importance) +print(learner$importance()) # Make predictions for the test rows predictions = learner$predict(task, row_ids = ids$test) @@ -127,6 +137,7 @@ RaphaelS1
                                                                                                                                                                                                                              Inherited methods
                                                                                                                                                                                                                              • mlr3::Learner$base_learner()
                                                                                                                                                                                                                              • +
                                                                                                                                                                                                                              • mlr3::Learner$encapsulate()
                                                                                                                                                                                                                              • mlr3::Learner$format()
                                                                                                                                                                                                                              • mlr3::Learner$help()
                                                                                                                                                                                                                              • mlr3::Learner$predict()
                                                                                                                                                                                                                              • diff --git a/man/mlr_learners_surv.glmboost.Rd b/man/mlr_learners_surv.glmboost.Rd index 76c4e74d8..3cd900c2c 100644 --- a/man/mlr_learners_surv.glmboost.Rd +++ b/man/mlr_learners_surv.glmboost.Rd @@ -8,21 +8,6 @@ Fits a generalized linear survival model using a boosting algorithm. Calls \code{\link[mboost:glmboost]{mboost::glmboost()}} from \CRANpkg{mboost}. } -\details{ -This learner returns up to three prediction types: -\enumerate{ -\item \code{crank}: same as \code{lp}. -\item \code{lp}: a vector of linear predictors (relative risk scores), one per -observation. -Calculated using \code{\link[mboost:methods]{mboost::predict.glmboost()}}. -\item \code{distr}: a survival matrix in two dimensions, where rows are observations -and columns are the time points. -This predict type is returned only when the \code{family} parameter is set to -\code{"coxph"} (which is the default). -Calculated using \code{\link[mboost:survFit]{mboost::survFit()}} which uses the Breslow estimator for the -baseline hazard function. -} -} \section{Dictionary}{ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{lrn()}: @@ -62,6 +47,25 @@ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{ } } +\section{Prediction types}{ + +This learner returns two to three prediction types: +\enumerate{ +\item \code{lp}: a vector containing the linear predictors (relative risk scores), +where each score corresponds to a specific test observation. +Calculated using \code{\link[mboost:methods]{mboost::predict.glmboost()}}. +If the \code{family} parameter is not \code{"coxph"}, \code{-lp} is returned, since non-coxph +families represent AFT-style distributions where lower \code{lp} values indicate higher risk. +\item \code{crank}: same as \code{lp}. +\item \code{distr}: a survival matrix in two dimensions, where observations are +represented in rows and time points in columns. +Calculated using \code{\link[mboost:survFit]{mboost::survFit()}}. +This prediction type is present only when the \code{family} distribution parameter +is equal to \code{"coxph"} (default). +By default the Breslow estimator is used for computing the baseline hazard. +} +} + \examples{ \dontshow{if (mlr3misc::require_namespaces(lrn("surv.glmboost")$packages, quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} # Define the Learner @@ -78,7 +82,7 @@ ids = mlr3::partition(task) learner$train(task, row_ids = ids$train) print(learner$model) -print(learner$importance) +print(learner$importance()) # Make predictions for the test rows predictions = learner$predict(task, row_ids = ids$test) @@ -122,6 +126,7 @@ RaphaelS1
                                                                                                                                                                                                                                Inherited methods
                                                                                                                                                                                                                                • mlr3::Learner$base_learner()
                                                                                                                                                                                                                                • +
                                                                                                                                                                                                                                • mlr3::Learner$encapsulate()
                                                                                                                                                                                                                                • mlr3::Learner$format()
                                                                                                                                                                                                                                • mlr3::Learner$help()
                                                                                                                                                                                                                                • mlr3::Learner$predict()
                                                                                                                                                                                                                                • diff --git a/man/mlr_learners_surv.glmnet.Rd b/man/mlr_learners_surv.glmnet.Rd index 89e533d7c..ab07e7b03 100644 --- a/man/mlr_learners_surv.glmnet.Rd +++ b/man/mlr_learners_surv.glmnet.Rd @@ -8,18 +8,27 @@ Generalized linear models with elastic net regularization. Calls \code{\link[glmnet:glmnet]{glmnet::glmnet()}} from package \CRANpkg{glmnet}. } -\details{ -This learner returns two prediction types: +\section{Initial parameter values}{ + +\itemize{ +\item \code{family} is set to \code{"cox"} and cannot be changed. +} +} + +\section{Prediction types}{ + +This learner returns three prediction types: \enumerate{ -\item \code{lp}: a vector of linear predictors (relative risk scores), one per -observation. -Calculated using \code{\link[glmnet:predict.coxnet]{glmnet::predict.coxnet()}}. +\item \code{lp}: a vector containing the linear predictors (relative risk scores), +where each score corresponds to a specific test observation. +Calculated using \code{\link[glmnet:predict.glmnet]{glmnet::predict.coxnet()}}. +\item \code{crank}: same as \code{lp}. \item \code{distr}: a survival matrix in two dimensions, where observations are represented in rows and time points in columns. Calculated using \code{\link[glmnet:survfit.coxnet]{glmnet::survfit.coxnet()}}. Parameters \code{stype} and \code{ctype} relate to how \code{lp} predictions are transformed into survival predictions and are described in \code{\link[survival:survfit.coxph]{survival::survfit.coxph()}}. -By default the Breslow estimator is used. +By default the Breslow estimator is used for computing the baseline hazard. } \strong{Caution}: This learner is different to learners calling \code{\link[glmnet:cv.glmnet]{glmnet::cv.glmnet()}} @@ -38,12 +47,6 @@ However, in some situations this is not applicable, usually when data are imbalanced or not i.i.d. (longitudinal, time-series) and tuning requires custom resampling strategies (blocked design, stratification). } -\section{Custom mlr3 parameters}{ - -\itemize{ -\item \code{family} is set to \code{"cox"} and cannot be changed. -} -} \section{Dictionary}{ @@ -170,6 +173,7 @@ be-marc
                                                                                                                                                                                                                                  Inherited methods
                                                                                                                                                                                                                                  • mlr3::Learner$base_learner()
                                                                                                                                                                                                                                  • +
                                                                                                                                                                                                                                  • mlr3::Learner$encapsulate()
                                                                                                                                                                                                                                  • mlr3::Learner$format()
                                                                                                                                                                                                                                  • mlr3::Learner$help()
                                                                                                                                                                                                                                  • mlr3::Learner$predict()
                                                                                                                                                                                                                                  • diff --git a/man/mlr_learners_surv.loghaz.Rd b/man/mlr_learners_surv.loghaz.Rd index 64d471031..93a843c38 100644 --- a/man/mlr_learners_surv.loghaz.Rd +++ b/man/mlr_learners_surv.loghaz.Rd @@ -14,6 +14,17 @@ Custom nets can be used in this learner either using the The number of output channels depends on the number of discretised time-points, i.e. the parameters \code{cuts} or \code{cutpoints}. } +\section{Prediction types}{ + +This learner returns two prediction types: +\enumerate{ +\item \code{distr}: a survival matrix in two dimensions, where observations are +represented in rows and time points in columns. +Calculated using the internal \code{\link[survivalmodels:predict.pycox]{survivalmodels::predict.pycox()}} function. +\item \code{crank}: the expected mortality using \code{\link[survivalmodels:surv_to_risk]{survivalmodels::surv_to_risk()}}. +} +} + \section{Dictionary}{ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{lrn()}: @@ -125,6 +136,7 @@ RaphaelS1
                                                                                                                                                                                                                                    Inherited methods
                                                                                                                                                                                                                                    • mlr3::Learner$base_learner()
                                                                                                                                                                                                                                    • +
                                                                                                                                                                                                                                    • mlr3::Learner$encapsulate()
                                                                                                                                                                                                                                    • mlr3::Learner$format()
                                                                                                                                                                                                                                    • mlr3::Learner$help()
                                                                                                                                                                                                                                    • mlr3::Learner$predict()
                                                                                                                                                                                                                                    • diff --git a/man/mlr_learners_surv.mboost.Rd b/man/mlr_learners_surv.mboost.Rd index 93a747ae1..0c6787253 100644 --- a/man/mlr_learners_surv.mboost.Rd +++ b/man/mlr_learners_surv.mboost.Rd @@ -11,6 +11,25 @@ Calls \code{\link[mboost:gamboost]{mboost::mboost()}} from \CRANpkg{mboost}. \details{ \code{distr} prediction made by \code{\link[mboost:survFit]{mboost::survFit()}}. } +\section{Prediction types}{ + +This learner returns two to three prediction types: +\enumerate{ +\item \code{lp}: a vector containing the linear predictors (relative risk scores), +where each score corresponds to a specific test observation. +Calculated using \code{\link[mboost:methods]{mboost::predict.mboost()}}. +If the \code{family} parameter is not \code{"coxph"}, \code{-lp} is returned, since non-coxph +families represent AFT-style distributions where lower \code{lp} values indicate higher risk. +\item \code{crank}: same as \code{lp}. +\item \code{distr}: a survival matrix in two dimensions, where observations are +represented in rows and time points in columns. +Calculated using \code{\link[mboost:survFit]{mboost::survFit()}}. +This prediction type is present only when the \code{family} distribution parameter +is equal to \code{"coxph"} (default). +By default the Breslow estimator is used for computing the baseline hazard. +} +} + \section{Dictionary}{ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{lrn()}: @@ -88,6 +107,7 @@ RaphaelS1
                                                                                                                                                                                                                                      Inherited methods
                                                                                                                                                                                                                                      • mlr3::Learner$base_learner()
                                                                                                                                                                                                                                      • +
                                                                                                                                                                                                                                      • mlr3::Learner$encapsulate()
                                                                                                                                                                                                                                      • mlr3::Learner$format()
                                                                                                                                                                                                                                      • mlr3::Learner$help()
                                                                                                                                                                                                                                      • mlr3::Learner$predict()
                                                                                                                                                                                                                                      • diff --git a/man/mlr_learners_surv.nelson.Rd b/man/mlr_learners_surv.nelson.Rd index 278cbe5c7..cf7026024 100644 --- a/man/mlr_learners_surv.nelson.Rd +++ b/man/mlr_learners_surv.nelson.Rd @@ -6,8 +6,22 @@ \title{Survival Nelson-Aalen Estimator Learner} \description{ Non-parametric estimator of the cumulative hazard rate function. -Calls \code{\link[survival:survfit]{survival::survfit()}} from \CRANpkg{survival}. +Calls \code{\link[survival:survfit]{survival::survfit()}} from \CRANpkg{survival}. } +\section{Prediction types}{ + +This learner returns two prediction types: +\enumerate{ +\item \code{distr}: a survival matrix in two dimensions, where observations are +represented in rows and time points in columns. +The cumulative hazard \eqn{H(t)} is calculated using the train data and the +default parameters of the \code{\link[survival:survfit]{survival::survfit()}} function, i.e. \code{ctype = 1}, +which uses the Nelson-Aalen formula. +Then for each test observation the survival curve is \eqn{S(t) = \exp{(-H(t))}}. +\item \code{crank}: the expected mortality using \code{\link[mlr3proba:dot-surv_return]{mlr3proba::.surv_return()}}. +} +} + \section{Dictionary}{ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{lrn()}: @@ -97,6 +111,7 @@ RaphaelS1
                                                                                                                                                                                                                                        Inherited methods
                                                                                                                                                                                                                                        • mlr3::Learner$base_learner()
                                                                                                                                                                                                                                        • +
                                                                                                                                                                                                                                        • mlr3::Learner$encapsulate()
                                                                                                                                                                                                                                        • mlr3::Learner$format()
                                                                                                                                                                                                                                        • mlr3::Learner$help()
                                                                                                                                                                                                                                        • mlr3::Learner$predict()
                                                                                                                                                                                                                                        • diff --git a/man/mlr_learners_surv.parametric.Rd b/man/mlr_learners_surv.parametric.Rd index d63af2c0f..dda83eb74 100644 --- a/man/mlr_learners_surv.parametric.Rd +++ b/man/mlr_learners_surv.parametric.Rd @@ -1,34 +1,22 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/learner_survival_surv_parametric.R +% Please edit documentation in R/learner_survivalmodels_surv_parametric.R \name{mlr_learners_surv.parametric} \alias{mlr_learners_surv.parametric} \alias{LearnerSurvParametric} \title{Survival Fully Parametric Learner} \description{ Parametric survival model. -Calls \verb{parametric()]} from 'survivalmodels'. +Calls \code{\link[survivalmodels:parametric]{survivalmodels::parametric()}} from package 'survivalmodels'. } \details{ -This learner allows you to choose a distribution and a model form to compose -a predicted survival probability distribution. +This learner allows you to choose a \strong{distribution} and a \strong{model form} to compose +a predicted survival probability distribution \eqn{S(t)}. The predict method is implemented in \code{\link[survivalmodels:predict.parametric]{survivalmodels::predict.parametric()}}. Our implementation is more efficient for composition to distributions than \code{\link[survival:predict.survreg]{survival::predict.survreg()}}. -Three types of prediction are returned for this learner: -\enumerate{ -\item \code{lp}: a vector of linear predictors (relative risk scores), one per test -observation. -\code{lp} is predicted using the formula \eqn{lp = X\beta} where \eqn{X} are the -variables in the test data set and \eqn{\beta} are the fitted coefficients. -\item \code{crank}: same as \code{lp}. -\item \code{distr}: a survival matrix in two dimensions, where observations are -represented in rows and time points in columns. -The distribution \code{distr} is composed using the \code{lp} predictions and specifying -a model form in the \code{form} hyper-parameter. These are as follows, with respective -survival functions: -} +The available model forms with their respective survival functions, are as follows: \itemize{ \item Accelerated Failure Time (\code{aft}) \deqn{S(t) = S_0(\frac{t}{exp(lp)})}{S(t) = S0(t/exp(lp))} \item Proportional Hazards (\code{ph}) \deqn{S(t) = S_0(t)^{exp(lp)}}{S(t) = S0(t)^exp(lp)} @@ -39,7 +27,7 @@ survival functions: where \eqn{S_0}{S0} is the estimated baseline survival distribution (in this case with a given parametric form), \eqn{lp} is the predicted linear -predictor, \eqn{\Phi} is the cdf of a N(0, 1) distribution, and \eqn{s} is +predictor, \eqn{\Phi} is the cdf of a \eqn{N(0, 1)} distribution, and \eqn{s} is the fitted scale parameter. Whilst any combination of distribution and model form is possible, this does @@ -57,14 +45,33 @@ the literature): \item dist = "loglogistic"; form = "po"; } } +\section{Prediction types}{ + +This learner returns three prediction types: +\enumerate{ +\item \code{lp}: a vector of linear predictors (relative risk scores), one per test +observation. +\code{lp} is predicted using the formula \eqn{lp = X\beta} where \eqn{X} are the +variables in the test data set and \eqn{\beta} are the fitted coefficients. +\item \code{crank}: same as \code{lp}. +\item \code{distr}: a survival matrix in two dimensions, where observations are +represented in rows and time points in columns. +The distribution \code{distr} is composed using the \code{lp} predictions and specifying +a model form in the \code{form} hyper-parameter, see Details. +The survival matrix uses the unique time points from the training set. +The parameter \code{ntime} allows to adjust the granularity of these time points +to any number (e.g. \code{150}). +} +} + \section{Custom mlr3 parameters}{ \itemize{ \item \code{discrete} determines the class of the returned survival probability -distribution. If \code{FALSE} (default) continuous probability -distributions are returned using \link[distr6:VectorDistribution]{distr6::VectorDistribution}, otherwise -\link[distr6:Matdist]{distr6::Matdist} (faster to calculate survival measures that require a -\code{distr} prediction type). +distribution. If \code{FALSE}, vectorized continuous probability distributions are +returned using \link[distr6:VectorDistribution]{distr6::VectorDistribution}, otherwise a \link[distr6:Matdist]{distr6::Matdist} +object, which is faster for calculating survival measures that require a \code{distr} +prediction type. Default option is \code{TRUE}. } } @@ -104,6 +111,8 @@ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{ score \tab logical \tab FALSE \tab TRUE, FALSE \tab - \cr cluster \tab untyped \tab - \tab \tab - \cr discrete \tab logical \tab - \tab TRUE, FALSE \tab - \cr + ntime \tab integer \tab NULL \tab \tab \eqn{[1, \infty)}{[1, Inf)} \cr + round_time \tab integer \tab 2 \tab \tab \eqn{[0, \infty)}{[0, Inf)} \cr } } @@ -171,6 +180,7 @@ bblodfon
                                                                                                                                                                                                                                          Inherited methods
                                                                                                                                                                                                                                          • mlr3::Learner$base_learner()
                                                                                                                                                                                                                                          • +
                                                                                                                                                                                                                                          • mlr3::Learner$encapsulate()
                                                                                                                                                                                                                                          • mlr3::Learner$format()
                                                                                                                                                                                                                                          • mlr3::Learner$help()
                                                                                                                                                                                                                                          • mlr3::Learner$predict()
                                                                                                                                                                                                                                          • diff --git a/man/mlr_learners_surv.pchazard.Rd b/man/mlr_learners_surv.pchazard.Rd index a8a343ab1..5aecf3b9e 100644 --- a/man/mlr_learners_surv.pchazard.Rd +++ b/man/mlr_learners_surv.pchazard.Rd @@ -15,6 +15,17 @@ Custom nets can be used in this learner either using the The number of output channels depends on the number of discretised time-points, i.e. the parameters \code{cuts} or \code{cutpoints}. } +\section{Prediction types}{ + +This learner returns two prediction types: +\enumerate{ +\item \code{distr}: a survival matrix in two dimensions, where observations are +represented in rows and time points in columns. +Calculated using the internal \code{\link[survivalmodels:predict.pycox]{survivalmodels::predict.pycox()}} function. +\item \code{crank}: the expected mortality using \code{\link[survivalmodels:surv_to_risk]{survivalmodels::surv_to_risk()}}. +} +} + \section{Dictionary}{ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{lrn()}: @@ -122,6 +133,7 @@ RaphaelS1
                                                                                                                                                                                                                                            Inherited methods
                                                                                                                                                                                                                                            • mlr3::Learner$base_learner()
                                                                                                                                                                                                                                            • +
                                                                                                                                                                                                                                            • mlr3::Learner$encapsulate()
                                                                                                                                                                                                                                            • mlr3::Learner$format()
                                                                                                                                                                                                                                            • mlr3::Learner$help()
                                                                                                                                                                                                                                            • mlr3::Learner$predict()
                                                                                                                                                                                                                                            • diff --git a/man/mlr_learners_surv.penalized.Rd b/man/mlr_learners_surv.penalized.Rd index 89fcc361c..f94b9c8b2 100644 --- a/man/mlr_learners_surv.penalized.Rd +++ b/man/mlr_learners_surv.penalized.Rd @@ -3,17 +3,37 @@ \name{mlr_learners_surv.penalized} \alias{mlr_learners_surv.penalized} \alias{LearnerSurvPenalized} -\title{Survival L1 and L2 Penalized Regression Learner} +\title{Survival L1 and L2 Penalized Cox Learner} \description{ -Penalized (L1 and L2) generalized linear models. +Penalized (L1 and L2) Cox Proportional Hazards model. Calls \code{\link[penalized:penalized]{penalized::penalized()}} from \CRANpkg{penalized}. } \details{ The \code{penalized} and \code{unpenalized} arguments in the learner are implemented slightly differently than in \code{\link[penalized:penalized]{penalized::penalized()}}. Here, there is no parameter for \code{penalized} but instead it is assumed that every variable is penalized unless stated in the \code{unpenalized} -parameter, see examples. +parameter. } +\section{Prediction types}{ + +This learner returns two prediction types: +\enumerate{ +\item \code{distr}: a survival matrix in two dimensions, where observations are +represented in rows and time points in columns. +Calculated using the internal \code{\link[penalized:predict]{penalized::predict()}} function. +By default the Breslow estimator \code{\link[penalized:breslow]{penalized::breslow()}} is used for computing +the baseline hazard. +\item \code{crank}: the expected mortality using \code{\link[mlr3proba:dot-surv_return]{mlr3proba::.surv_return()}}. +} +} + +\section{Initial parameter values}{ + +\itemize{ +\item \code{trace} is set to \code{"FALSE"} to disable printing output during model training. +} +} + \section{Dictionary}{ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{lrn()}: @@ -101,6 +121,7 @@ RaphaelS1 \subsection{Public methods}{ \itemize{ \item \href{#method-LearnerSurvPenalized-new}{\code{LearnerSurvPenalized$new()}} +\item \href{#method-LearnerSurvPenalized-selected_features}{\code{LearnerSurvPenalized$selected_features()}} \item \href{#method-LearnerSurvPenalized-clone}{\code{LearnerSurvPenalized$clone()}} } } @@ -108,6 +129,7 @@ RaphaelS1
                                                                                                                                                                                                                                              Inherited methods
                                                                                                                                                                                                                                              • mlr3::Learner$base_learner()
                                                                                                                                                                                                                                              • +
                                                                                                                                                                                                                                              • mlr3::Learner$encapsulate()
                                                                                                                                                                                                                                              • mlr3::Learner$format()
                                                                                                                                                                                                                                              • mlr3::Learner$help()
                                                                                                                                                                                                                                              • mlr3::Learner$predict()
                                                                                                                                                                                                                                              • @@ -127,6 +149,25 @@ Creates a new instance of this \link[R6:R6Class]{R6} class. \if{html}{\out{
                                                                                                                                                                                                                                                }}\preformatted{LearnerSurvPenalized$new()}\if{html}{\out{
                                                                                                                                                                                                                                                }} } +} +\if{html}{\out{
                                                                                                                                                                                                                                                }} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-LearnerSurvPenalized-selected_features}{}}} +\subsection{Method \code{selected_features()}}{ +Selected features are extracted with the method \code{coef()} of the S4 model +object, see \code{\link[penalized:penfit]{penalized::penfit()}}. +By default it returns features with non-zero coefficients. + +\strong{Note}: Selected features can be retrieved only for datasets with +\code{numeric} features, as the presence of factors with multiple levels makes +it difficult to get the original feature names. +\subsection{Usage}{ +\if{html}{\out{
                                                                                                                                                                                                                                                }}\preformatted{LearnerSurvPenalized$selected_features()}\if{html}{\out{
                                                                                                                                                                                                                                                }} +} + +\subsection{Returns}{ +\code{character()}. +} } \if{html}{\out{
                                                                                                                                                                                                                                                }} \if{html}{\out{}} diff --git a/man/mlr_learners_surv.priority_lasso.Rd b/man/mlr_learners_surv.priority_lasso.Rd index c16034a3f..81edad8e5 100644 --- a/man/mlr_learners_surv.priority_lasso.Rd +++ b/man/mlr_learners_surv.priority_lasso.Rd @@ -7,7 +7,34 @@ \description{ Patient outcome prediction based on multi-omics data taking practitioners’ preferences into account. Calls \code{\link[prioritylasso:prioritylasso]{prioritylasso::prioritylasso()}} from \CRANpkg{prioritylasso}. +Many parameters for this survival learner are the same as \link{mlr_learners_surv.cv_glmnet} +as \code{prioritylasso()} calls \code{\link[glmnet:cv.glmnet]{glmnet::cv.glmnet()}} during training phase. +Note that \code{prioritylasso()} has ways to deal with block-wise missing data, +but this feature is not supported currently. } +\section{Prediction types}{ + +This learner returns three prediction types: +\enumerate{ +\item \code{lp}: a vector containing the linear predictors (relative risk scores), +where each score corresponds to a specific test observation. +Calculated using \code{\link[prioritylasso:predict.prioritylasso]{prioritylasso::predict.prioritylasso()}}. +\item \code{crank}: same as \code{lp}. +\item \code{distr}: a survival matrix in two dimensions, where observations are +represented in rows and time points in columns. +Calculated using \code{\link[mlr3proba:breslow]{mlr3proba::breslow()}} where the Breslow estimator is used +for computing the baseline hazard. +} +} + +\section{Initial parameter values}{ + +\itemize{ +\item \code{family} is set to \code{"cox"} for the Cox survival objective and cannot be changed +\item \code{type.measure} set to \code{"deviance"} (cross-validation measure) +} +} + \section{Dictionary}{ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{lrn()}: @@ -20,7 +47,7 @@ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{ \itemize{ \item Task type: \dQuote{surv} -\item Predict Types: \dQuote{lp}, \dQuote{response} +\item Predict Types: \dQuote{crank}, \dQuote{distr}, \dQuote{lp} \item Feature Types: \dQuote{logical}, \dQuote{integer}, \dQuote{numeric} \item Required Packages: \CRANpkg{mlr3}, \CRANpkg{mlr3proba}, \CRANpkg{prioritylasso} } @@ -39,7 +66,6 @@ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{ cvoffset \tab logical \tab FALSE \tab TRUE, FALSE \tab - \cr cvoffsetnfolds \tab integer \tab 10 \tab \tab \eqn{[1, \infty)}{[1, Inf)} \cr return.x \tab logical \tab TRUE \tab TRUE, FALSE \tab - \cr - handle.missingtestdata \tab character \tab - \tab none, omit.prediction, set.zero, impute.block \tab - \cr include.allintercepts \tab logical \tab FALSE \tab TRUE, FALSE \tab - \cr use.blocks \tab untyped \tab "all" \tab \tab - \cr alignment \tab character \tab lambda \tab lambda, fraction \tab - \cr @@ -77,14 +103,33 @@ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{ type.logistic \tab character \tab Newton \tab Newton, modified.Newton \tab - \cr type.multinomial \tab character \tab ungrouped \tab ungrouped, grouped \tab - \cr upper.limits \tab untyped \tab Inf \tab \tab - \cr - predict.gamma \tab numeric \tab gamma.1se \tab \tab \eqn{(-\infty, \infty)}{(-Inf, Inf)} \cr relax \tab logical \tab FALSE \tab TRUE, FALSE \tab - \cr - s \tab numeric \tab lambda.1se \tab \tab \eqn{[0, 1]}{[0, 1]} \cr } } \examples{ -lrn("surv.priority_lasso") +\dontshow{if (mlr3misc::require_namespaces(c("mlr3proba"), quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +# Define a Task +task = tsk("grace") +# Create train and test set +ids = partition(task) +# check task's features +task$feature_names +# partition features to 2 blocks +blocks = list(bl1 = 1:3, bl2 = 4:6) +# define learner +learner = lrn("surv.priority_lasso", blocks = blocks, block1.penalization = FALSE, + lambda.type = "lambda.1se", standardize = TRUE, nfolds = 5) +# Train the learner on the training ids +learner$train(task, row_ids = ids$train) +# selected features +learner$selected_features() +# Make predictions for the test observations +pred = learner$predict(task, row_ids = ids$test) +pred +# Score the predictions +pred$score() +\dontshow{\}) # examplesIf} } \references{ Simon K, Vindi J, Roman H, Tobias H, Anne-Laure B (2018). @@ -121,6 +166,7 @@ HarutyunyanLiana
                                                                                                                                                                                                                                                Inherited methods
                                                                                                                                                                                                                                                • mlr3::Learner$base_learner()
                                                                                                                                                                                                                                                • +
                                                                                                                                                                                                                                                • mlr3::Learner$encapsulate()
                                                                                                                                                                                                                                                • mlr3::Learner$format()
                                                                                                                                                                                                                                                • mlr3::Learner$help()
                                                                                                                                                                                                                                                • mlr3::Learner$predict()
                                                                                                                                                                                                                                                • @@ -145,7 +191,7 @@ Creates a new instance of this \link[R6:R6Class]{R6} class. \if{html}{\out{}} \if{latex}{\out{\hypertarget{method-LearnerSurvPriorityLasso-selected_features}{}}} \subsection{Method \code{selected_features()}}{ -Selected features, i.e. those where the coefficient is positive. +Selected features, i.e. those where the coefficient is non-zero. \subsection{Usage}{ \if{html}{\out{
                                                                                                                                                                                                                                                  }}\preformatted{LearnerSurvPriorityLasso$selected_features()}\if{html}{\out{
                                                                                                                                                                                                                                                  }} } diff --git a/man/mlr_learners_surv.ranger.Rd b/man/mlr_learners_surv.ranger.Rd index 115d8e97c..227e975b3 100644 --- a/man/mlr_learners_surv.ranger.Rd +++ b/man/mlr_learners_surv.ranger.Rd @@ -8,17 +8,25 @@ Random survival forest. Calls \code{\link[ranger:ranger]{ranger::ranger()}} from package \CRANpkg{ranger}. } +\section{Prediction types}{ + +This learner returns two prediction types: +\enumerate{ +\item \code{distr}: a survival matrix in two dimensions, where observations are +represented in rows and (unique event) time points in columns. +Calculated using the internal \code{\link[ranger:predict.ranger]{ranger::predict.ranger()}} function. +\item \code{crank}: the expected mortality using \code{\link[mlr3proba:dot-surv_return]{mlr3proba::.surv_return()}}. +} +} + \section{Custom mlr3 parameters}{ \itemize{ -\item \code{mtry}: -\itemize{ -\item This hyperparameter can alternatively be set via our hyperparameter \code{mtry.ratio} -as \code{mtry = max(ceiling(mtry.ratio * n_features), 1)}. +\item \code{mtry}: This hyperparameter can alternatively be set via our hyperparameter +\code{mtry.ratio} as \code{mtry = max(ceiling(mtry.ratio * n_features), 1)}. Note that \code{mtry} and \code{mtry.ratio} are mutually exclusive. } } -} \section{Initial parameter values}{ @@ -81,9 +89,9 @@ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{ } \examples{ -\dontshow{if (mlr3misc::require_namespaces(lrn("surv.ranger")$packages, quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (requireNamespace("ranger", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} # Define the Learner -learner = mlr3::lrn("surv.ranger") +learner = mlr3::lrn("surv.ranger", importance = "permutation") print(learner) # Define a Task @@ -96,7 +104,7 @@ ids = mlr3::partition(task) learner$train(task, row_ids = ids$train) print(learner$model) -print(learner$importance) +print(learner$importance()) # Make predictions for the test rows predictions = learner$predict(task, row_ids = ids$test) @@ -146,6 +154,7 @@ be-marc
                                                                                                                                                                                                                                                  Inherited methods
                                                                                                                                                                                                                                                  • mlr3::Learner$base_learner()
                                                                                                                                                                                                                                                  • +
                                                                                                                                                                                                                                                  • mlr3::Learner$encapsulate()
                                                                                                                                                                                                                                                  • mlr3::Learner$format()
                                                                                                                                                                                                                                                  • mlr3::Learner$help()
                                                                                                                                                                                                                                                  • mlr3::Learner$predict()
                                                                                                                                                                                                                                                  • diff --git a/man/mlr_learners_surv.rfsrc.Rd b/man/mlr_learners_surv.rfsrc.Rd index c810350e9..9312eca6e 100644 --- a/man/mlr_learners_surv.rfsrc.Rd +++ b/man/mlr_learners_surv.rfsrc.Rd @@ -8,13 +8,17 @@ Random survival forest. Calls \code{\link[randomForestSRC:rfsrc]{randomForestSRC::rfsrc()}} from \CRANpkg{randomForestSRC}. } -\details{ -\code{\link[randomForestSRC:predict.rfsrc]{randomForestSRC::predict.rfsrc()}} returns both cumulative hazard function (chf) and -survival function (surv) but uses different estimators to derive these. \code{chf} uses a -bootstrapped Nelson-Aalen estimator, (Ishwaran, 2008) whereas \code{surv} uses a bootstrapped -Kaplan-Meier estimator. The choice of which estimator to use is given by the extra -\code{estimator} hyper-parameter, default is \code{nelson}. +\section{Prediction types}{ + +This learner returns two prediction types: +\enumerate{ +\item \code{distr}: a survival matrix in two dimensions, where observations are +represented in rows and (unique event) time points in columns. +Calculated using the internal \code{\link[randomForestSRC:predict.rfsrc]{randomForestSRC::predict.rfsrc()}} function. +\item \code{crank}: the expected mortality using \code{\link[mlr3proba:dot-surv_return]{mlr3proba::.surv_return()}}. +} } + \section{Dictionary}{ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{lrn()}: @@ -36,7 +40,7 @@ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{ \section{Parameters}{ \tabular{lllll}{ Id \tab Type \tab Default \tab Levels \tab Range \cr - ntree \tab integer \tab 1000 \tab \tab \eqn{[1, \infty)}{[1, Inf)} \cr + ntree \tab integer \tab 500 \tab \tab \eqn{[1, \infty)}{[1, Inf)} \cr mtry \tab integer \tab - \tab \tab \eqn{[1, \infty)}{[1, Inf)} \cr mtry.ratio \tab numeric \tab - \tab \tab \eqn{[0, 1]}{[0, 1]} \cr nodesize \tab integer \tab 15 \tab \tab \eqn{[1, \infty)}{[1, Inf)} \cr @@ -53,7 +57,7 @@ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{ sampsize.ratio \tab numeric \tab - \tab \tab \eqn{[0, 1]}{[0, 1]} \cr na.action \tab character \tab na.omit \tab na.omit, na.impute \tab - \cr nimpute \tab integer \tab 1 \tab \tab \eqn{[1, \infty)}{[1, Inf)} \cr - ntime \tab integer \tab - \tab \tab \eqn{[1, \infty)}{[1, Inf)} \cr + ntime \tab integer \tab 150 \tab \tab \eqn{[0, \infty)}{[0, Inf)} \cr cause \tab integer \tab - \tab \tab \eqn{[1, \infty)}{[1, Inf)} \cr proximity \tab character \tab FALSE \tab FALSE, TRUE, inbag, oob, all \tab - \cr distance \tab character \tab FALSE \tab FALSE, TRUE, inbag, oob, all \tab - \cr @@ -80,27 +84,41 @@ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{ \section{Custom mlr3 parameters}{ \itemize{ -\item \code{mtry}: -\itemize{ -\item This hyperparameter can alternatively be set via the added hyperparameter \code{mtry.ratio} -as \code{mtry = max(ceiling(mtry.ratio * n_features), 1)}. -Note that \code{mtry} and \code{mtry.ratio} are mutually exclusive. +\item \code{estimator}: Hidden parameter that controls the type of estimator used to +derive the survival function during prediction. The \strong{default} value is \code{"chf"} which +uses a bootstrapped Nelson-Aalen estimator for the cumulative hazard function +\eqn{H(t)}, (Ishwaran, 2008) from which we calculate \eqn{S(t) = \exp(-H(t))}, +whereas \code{"surv"} uses a bootstrapped Kaplan-Meier estimator to directly estimate +\eqn{S(t)}. } -\item \code{sampsize}: + + \itemize{ -\item This hyperparameter can alternatively be set via the added hyperparameter \code{sampsize.ratio} -as \code{sampsize = max(ceiling(sampsize.ratio * n_obs), 1)}. +\item \code{mtry}: This hyperparameter can alternatively be set via the added +hyperparameter \code{mtry.ratio} as \code{mtry = max(ceiling(mtry.ratio * n_features), 1)}. +Note that \code{mtry} and \code{mtry.ratio} are mutually exclusive. +\item \code{sampsize}: This hyperparameter can alternatively be set via the added +hyperparameter \code{sampsize.ratio} as \code{sampsize = max(ceiling(sampsize.ratio * n_obs), 1)}. Note that \code{sampsize} and \code{sampsize.ratio} are mutually exclusive. +\item \code{cores}: This value is set as the option \code{rf.cores} during training and is +set to 1 by default. +} } -\item \code{cores}: -This value is set as the option \code{rf.cores} during training and is set to 1 by default. + +\section{Initial parameter values}{ + +\itemize{ +\item \code{ntime}: Number of time points to coerce the observed event times for use in the +estimated survival function during prediction. We changed the default value +of \code{150} to \code{0} in order to be in line with other random survival forest +learners and use all the \strong{unique event times from the train set}. } } \examples{ -\dontshow{if (mlr3misc::require_namespaces(lrn("surv.rfsrc")$packages, quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (requireNamespace("randomForestSRC", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} # Define the Learner -learner = mlr3::lrn("surv.rfsrc") +learner = mlr3::lrn("surv.rfsrc", importance = "TRUE") print(learner) # Define a Task @@ -113,7 +131,7 @@ ids = mlr3::partition(task) learner$train(task, row_ids = ids$train) print(learner$model) -print(learner$importance) +print(learner$importance()) # Make predictions for the test rows predictions = learner$predict(task, row_ids = ids$test) @@ -164,6 +182,7 @@ RaphaelS1
                                                                                                                                                                                                                                                    Inherited methods
                                                                                                                                                                                                                                                    • mlr3::Learner$base_learner()
                                                                                                                                                                                                                                                    • +
                                                                                                                                                                                                                                                    • mlr3::Learner$encapsulate()
                                                                                                                                                                                                                                                    • mlr3::Learner$format()
                                                                                                                                                                                                                                                    • mlr3::Learner$help()
                                                                                                                                                                                                                                                    • mlr3::Learner$predict()
                                                                                                                                                                                                                                                    • diff --git a/man/mlr_learners_surv.svm.Rd b/man/mlr_learners_surv.svm.Rd index f3851a79e..97680d993 100644 --- a/man/mlr_learners_surv.svm.Rd +++ b/man/mlr_learners_surv.svm.Rd @@ -40,7 +40,8 @@ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{ Id \tab Type \tab Default \tab Levels \tab Range \cr type \tab character \tab regression \tab regression, vanbelle1, vanbelle2, hybrid \tab - \cr diff.meth \tab character \tab - \tab makediff1, makediff2, makediff3 \tab - \cr - gamma.mu \tab untyped \tab - \tab \tab - \cr + gamma \tab numeric \tab NULL \tab \tab \eqn{(-\infty, \infty)}{(-Inf, Inf)} \cr + mu \tab numeric \tab NULL \tab \tab \eqn{(-\infty, \infty)}{(-Inf, Inf)} \cr opt.meth \tab character \tab quadprog \tab quadprog, ipop \tab - \cr kernel \tab character \tab lin_kernel \tab lin_kernel, add_kernel, rbf_kernel, poly_kernel \tab - \cr kernel.pars \tab untyped \tab - \tab \tab - \cr @@ -55,11 +56,30 @@ This \link[mlr3:Learner]{Learner} can be instantiated via \link[mlr3:mlr_sugar]{ } } +\section{Prediction types}{ + +This learner returns up to two prediction types: +\enumerate{ +\item \code{crank}: a vector containing the continuous ranking scores, where each score +corresponds to a specific test observation. +\item \code{response}: the survival time of each test observation, equal to \code{-crank}. +This prediction type if only available for \code{"type"} equal to \code{regression} or \code{hybrid}. +} +} + +\section{Custom mlr3 parameters}{ + +\itemize{ +\item \code{gamma}, \code{mu} have replaced \code{gamma.mu} so that it's easier to tune these separately. +\code{mu} is only used when \code{type = "hybrid"}. +} +} + \examples{ \dontshow{if (mlr3misc::require_namespaces(c("mlr3extralearners", "survivalsvm"), quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} set.seed(123) # Define the Learner and set parameter values -learner = lrn("surv.svm", gamma.mu = 0.1) +learner = lrn("surv.svm", gamma = 0.1) print(learner) # Define a Task @@ -123,6 +143,7 @@ RaphaelS1
                                                                                                                                                                                                                                                      Inherited methods
                                                                                                                                                                                                                                                      • mlr3::Learner$base_learner()
                                                                                                                                                                                                                                                      • +
                                                                                                                                                                                                                                                      • mlr3::Learner$encapsulate()
                                                                                                                                                                                                                                                      • mlr3::Learner$format()
                                                                                                                                                                                                                                                      • mlr3::Learner$help()
                                                                                                                                                                                                                                                      • mlr3::Learner$predict()
                                                                                                                                                                                                                                                      • diff --git a/man/mlr_learners_surv.xgboost.aft.Rd b/man/mlr_learners_surv.xgboost.aft.Rd index 2d1842c26..bee360757 100644 --- a/man/mlr_learners_surv.xgboost.aft.Rd +++ b/man/mlr_learners_surv.xgboost.aft.Rd @@ -10,7 +10,13 @@ objective. Calls \code{\link[xgboost:xgb.train]{xgboost::xgb.train()}} from package \CRANpkg{xgboost} with \code{objective} set to \code{survival:aft} and \code{eval_metric} to \code{aft-nloglik}. } -\details{ +\note{ +To compute on GPUs, you first need to compile \CRANpkg{xgboost} yourself and link +against CUDA. +See \url{https://xgboost.readthedocs.io/en/stable/build.html#building-with-gpu-support}. +} +\section{Prediction types}{ + This learner returns three prediction types: \enumerate{ \item \code{response}: the estimated survival time \eqn{T} for each test observation. @@ -20,11 +26,7 @@ Higher survival time denotes lower risk. \item \code{crank}: same as \code{lp}. } } -\note{ -To compute on GPUs, you first need to compile \CRANpkg{xgboost} yourself and link -against CUDA. -See \url{https://xgboost.readthedocs.io/en/stable/build.html#building-with-gpu-support}. -} + \section{Initial parameter values}{ \itemize{ @@ -36,22 +38,6 @@ See \url{https://xgboost.readthedocs.io/en/stable/build.html#building-with-gpu-s \section{Early stopping}{ -Early stopping can be used to find the optimal number of boosting rounds. -The \code{early_stopping_set} parameter controls which set is used to monitor the -performance. -By default, \code{early_stopping_set = "none"} which disables early stopping. -Set \code{early_stopping_set = "test"} to monitor the performance of the model on -the test set while training. -The test set for early stopping can be set with the \code{"test"} row role in the -\link[mlr3:Task]{mlr3::Task}. -Additionally, the range must be set in which the performance must increase -with \code{early_stopping_rounds} and the maximum number of boosting rounds with -\code{nrounds}. -While resampling, the test set is automatically applied from the \link[mlr3:Resampling]{mlr3::Resampling}. -Not that using the test set for early stopping can potentially bias the -performance scores. - - Early stopping can be used to find the optimal number of boosting rounds. The \code{early_stopping_set} parameter controls which set is used to monitor the performance. @@ -163,7 +149,7 @@ ids = mlr3::partition(task) learner$train(task, row_ids = ids$train) print(learner$model) -print(learner$importance) +print(learner$importance()) # Make predictions for the test rows predictions = learner$predict(task, row_ids = ids$test) @@ -226,6 +212,7 @@ a ratio, \code{"test"}, or \code{"predefined"}.}
                                                                                                                                                                                                                                                        Inherited methods
                                                                                                                                                                                                                                                        • mlr3::Learner$base_learner()
                                                                                                                                                                                                                                                        • +
                                                                                                                                                                                                                                                        • mlr3::Learner$encapsulate()
                                                                                                                                                                                                                                                        • mlr3::Learner$format()
                                                                                                                                                                                                                                                        • mlr3::Learner$help()
                                                                                                                                                                                                                                                        • mlr3::Learner$predict()
                                                                                                                                                                                                                                                        • diff --git a/man/mlr_learners_surv.xgboost.cox.Rd b/man/mlr_learners_surv.xgboost.cox.Rd index ce2c2623f..bb11e99ab 100644 --- a/man/mlr_learners_surv.xgboost.cox.Rd +++ b/man/mlr_learners_surv.xgboost.cox.Rd @@ -10,7 +10,13 @@ objective. Calls \code{\link[xgboost:xgb.train]{xgboost::xgb.train()}} from package \CRANpkg{xgboost} with \code{objective} set to \code{survival:cox} and \code{eval_metric} to \code{cox-nloglik}. } -\details{ +\note{ +To compute on GPUs, you first need to compile \CRANpkg{xgboost} yourself and link +against CUDA. +See \url{https://xgboost.readthedocs.io/en/stable/build.html#building-with-gpu-support}. +} +\section{Prediction types}{ + Three types of prediction are returned for this learner: \enumerate{ \item \code{lp}: a vector of linear predictors (relative risk scores), one per @@ -21,11 +27,7 @@ represented in rows and time points in columns. By default, the Breslow estimator is used via \code{\link[mlr3proba:breslow]{mlr3proba::breslow()}}. } } -\note{ -To compute on GPUs, you first need to compile \CRANpkg{xgboost} yourself and link -against CUDA. -See \url{https://xgboost.readthedocs.io/en/stable/build.html#building-with-gpu-support}. -} + \section{Initial parameter values}{ \itemize{ @@ -145,7 +147,7 @@ ids = mlr3::partition(task) learner$train(task, row_ids = ids$train) print(learner$model) -print(learner$importance) +print(learner$importance()) # Make predictions for the test rows predictions = learner$predict(task, row_ids = ids$test) @@ -203,6 +205,7 @@ a ratio, \code{"test"}, or \code{"predefined"}.}
                                                                                                                                                                                                                                                          Inherited methods
                                                                                                                                                                                                                                                          • mlr3::Learner$base_learner()
                                                                                                                                                                                                                                                          • +
                                                                                                                                                                                                                                                          • mlr3::Learner$encapsulate()
                                                                                                                                                                                                                                                          • mlr3::Learner$format()
                                                                                                                                                                                                                                                          • mlr3::Learner$help()
                                                                                                                                                                                                                                                          • mlr3::Learner$predict()
                                                                                                                                                                                                                                                          • diff --git a/tests/testthat/test_aorsf_surv_aorsf.R b/tests/testthat/test_aorsf_surv_aorsf.R index 3e073fc24..6f488b3dd 100644 --- a/tests/testthat/test_aorsf_surv_aorsf.R +++ b/tests/testthat/test_aorsf_surv_aorsf.R @@ -1,4 +1,3 @@ - test_that("autotest", { set.seed(1) # there was presumable a weird bug learner = lrn("surv.aorsf") diff --git a/tests/testthat/test_paramtest_prioritylasso_surv_priority_lasso.R b/tests/testthat/test_paramtest_prioritylasso_surv_priority_lasso.R index b73fb34bb..3e5f53640 100644 --- a/tests/testthat/test_paramtest_prioritylasso_surv_priority_lasso.R +++ b/tests/testthat/test_paramtest_prioritylasso_surv_priority_lasso.R @@ -29,7 +29,9 @@ test_that("surv.priority_lasso predict", { "type", # handled internally "lambda.type", # predict.glmnet "predict.gamma", # is passed as gamma to predict.glmnet - "s" # predict.glmnet + "s", # predict.glmnet + "handle.missingtestdata" # we don't support missing data both in train + # (`mcontrol` parameter) therefore also not during prediction ) paramtest = run_paramtest(learner, fun, exclude, tag = "predict") diff --git a/tests/testthat/test_paramtest_survival_surv_parametric.R b/tests/testthat/test_paramtest_survivalmodels_surv_parametric.R similarity index 100% rename from tests/testthat/test_paramtest_survival_surv_parametric.R rename to tests/testthat/test_paramtest_survivalmodels_surv_parametric.R diff --git a/tests/testthat/test_paramtest_survivalsvm_surv_svm.R b/tests/testthat/test_paramtest_survivalsvm_surv_svm.R index 88650af4a..8cd7ea888 100644 --- a/tests/testthat/test_paramtest_survivalsvm_surv_svm.R +++ b/tests/testthat/test_paramtest_survivalsvm_surv_svm.R @@ -6,7 +6,8 @@ test_that("paramtest surv.svm_train", { "data", # coerced internally by task "subset", # coerced internally by task "time.variable.name", # unused alternative formulation to formula - "status.variable.name" # unused alternative formulation to formula + "status.variable.name", # unused alternative formulation to formula + "gamma.mu", "gamma", "mu" # we split the original parameter to two new ones ) paramtest = run_paramtest(learner, fun, exclude, tag = "train") diff --git a/tests/testthat/test_penalized_surv_penalized.R b/tests/testthat/test_penalized_surv_penalized.R index 6b9a94963..7063782c1 100644 --- a/tests/testthat/test_penalized_surv_penalized.R +++ b/tests/testthat/test_penalized_surv_penalized.R @@ -1,5 +1,5 @@ test_that("autotest", { - learner = lrn("surv.penalized", trace = FALSE) + learner = lrn("surv.penalized") expect_learner(learner) result = run_autotest(learner, check_replicable = FALSE) expect_true(result, info = result$error) @@ -7,9 +7,20 @@ test_that("autotest", { test_that("unpenalized", { task = tsk("rats") - learner = lrn("surv.penalized", unpenalized = c("litter"), trace = FALSE) + learner = lrn("surv.penalized", unpenalized = "litter") learner$train(task) - expect_equal(names(learner$model@penalized), c("rx", "sexm")) - expect_equal(names(learner$model@unpenalized), c("litter")) + expect_equal(names(learner$model$model@penalized), c("rx", "sexm")) + expect_equal(names(learner$model$model@unpenalized), c("litter")) expect_prediction_surv(learner$predict(task)) + # unpenalized features have to be in present + learner = lrn("surv.penalized", unpenalized = "li") + expect_error(learner$train(task), "values not present in task") +}) + +test_that("can't get selected features on task with factors", { + task = tsk("lung") + learner = lrn("surv.penalized") + learner$train(task) + expect_class(learner$model$model, "penfit") + expect_error(learner$selected_features()) }) diff --git a/tests/testthat/test_survivalmodels_surv_akritas.R b/tests/testthat/test_survivalmodels_surv_akritas.R index 44218c0b4..07b9063da 100644 --- a/tests/testthat/test_survivalmodels_surv_akritas.R +++ b/tests/testthat/test_survivalmodels_surv_akritas.R @@ -6,3 +6,25 @@ test_that("autotest", { # whereas the sanity check requires >= 0.6 expect_true(result, info = result$error) }) + +test_that("time points for prediction", { + task = tsk("lung") + learner = lrn("surv.akritas") + p = learner$train(task)$predict(task) + times = as.integer(colnames(p$data$distr)) + expect_equal(times, task$unique_times()) # unique train time points are used + + # use many more time points than the ones in the train set + learner$param_set$set_values(.values = list(ntime = 9999)) + p = learner$train(task)$predict(task) + times = as.integer(colnames(p$data$distr)) + expect_equal(times, task$unique_times()) # all unique train time points are still used + + learner$param_set$set_values(.values = list(ntime = 50)) + p = learner$train(task)$predict(task) + times = as.integer(colnames(p$data$distr)) + # min and max times are retained after coersion + expect_equal(min(times), min(task$unique_times())) + expect_equal(max(times), max(task$unique_times())) + expect_equal(length(times), 50) +}) diff --git a/tests/testthat/test_survival_surv_parametric.R b/tests/testthat/test_survivalmodels_surv_parametric.R similarity index 79% rename from tests/testthat/test_survival_surv_parametric.R rename to tests/testthat/test_survivalmodels_surv_parametric.R index 0f7bef175..e0c7a106c 100644 --- a/tests/testthat/test_survival_surv_parametric.R +++ b/tests/testthat/test_survivalmodels_surv_parametric.R @@ -8,7 +8,7 @@ test_that("autotest aft", { test_that("autotest ph", { set.seed(1) - learner = lrn("surv.parametric", form = "ph", discrete = TRUE) + learner = lrn("surv.parametric", form = "ph", discrete = FALSE) expect_learner(learner) result = run_autotest(learner, check_replicable = FALSE, exclude = "utf8_feature_names") expect_true(result, info = result$error) @@ -24,8 +24,29 @@ test_that("autotest po", { task = tsk("lung") +test_that("time points for prediction", { + learner = lrn("surv.parametric") + p = learner$train(task)$predict(task) + times = as.integer(colnames(p$data$distr)) + expect_equal(times, task$unique_times()) # unique train time points are used + + # use many more time points than the ones in the train set + learner$param_set$set_values(.values = list(ntime = 9999)) + p = learner$train(task)$predict(task) + times = as.integer(colnames(p$data$distr)) + expect_equal(times, task$unique_times()) # all unique train time points are still used + + learner$param_set$set_values(.values = list(ntime = 50)) + p = learner$train(task)$predict(task) + times = as.integer(colnames(p$data$distr)) + # min and max times are retained after coersion + expect_equal(min(times), min(task$unique_times())) + expect_equal(max(times), max(task$unique_times())) + expect_equal(length(times), 50) +}) + test_that("manualtest - aft", { - learner = lrn("surv.parametric", dist = "weibull", form = "aft") + learner = lrn("surv.parametric", dist = "weibull", form = "aft", discrete = FALSE) expect_silent(learner$train(task)) p = learner$predict(task) expect_prediction_surv(p) @@ -38,7 +59,7 @@ test_that("manualtest - aft", { )[10, ]), seq.int(0, 1, 0.1)) - learner = lrn("surv.parametric", dist = "lognormal", form = "aft")$train(task) + learner = lrn("surv.parametric", dist = "lognormal", form = "aft", discrete = FALSE)$train(task) p = learner$predict(task) expect_equal(p$distr[15]$cdf(predict( learner$model$model, type = "quantile", p = seq.int(0, 1, 0.1) @@ -52,43 +73,43 @@ test_that("missing", { }) test_that("quantile type", { - learner = lrn("surv.parametric", dist = "weibull", form = "aft")$train(task) - p = lrn("surv.parametric", dist = "weibull", form = "aft")$train(task)$predict(task) + learner = lrn("surv.parametric", dist = "weibull", form = "aft", discrete = FALSE)$train(task) + p = lrn("surv.parametric", dist = "weibull", form = "aft", discrete = FALSE)$train(task)$predict(task) quantile = p$distr$quantile(c(0.2, 0.8)) expect_equal(matrix(t(quantile), ncol = 2), predict(learner$model$model, type = "quantile", p = c(0.2, 0.8))) quantile = p$distr$quantile(0.5) expect_equal(unlist(p$distr$cdf(quantile), use.names = FALSE), rep(0.5, task$nrow)) - p = lrn("surv.parametric", dist = "weibull", form = "ph")$train(task)$predict(task) + p = lrn("surv.parametric", dist = "weibull", form = "ph", discrete = FALSE)$train(task)$predict(task) quantile = p$distr$quantile(0.5) expect_equal(unlist(p$distr$cdf(quantile), use.names = FALSE), rep(0.5, task$nrow)) - p = lrn("surv.parametric", dist = "weibull", form = "po")$train(task)$predict(task) + p = lrn("surv.parametric", dist = "weibull", form = "po", discrete = FALSE)$train(task)$predict(task) quantile = p$distr$quantile(0.5) expect_equal(unlist(p$distr$cdf(quantile), use.names = FALSE), rep(0.5, task$nrow)) }) test_that("quantile dist", { - learner = lrn("surv.parametric", dist = "weibull", form = "aft")$train(task) + learner = lrn("surv.parametric", dist = "weibull", form = "aft", discrete = FALSE)$train(task) p = learner$predict(task) quantile = p$distr$quantile(c(0.2, 0.8)) expect_equal(matrix(t(quantile), ncol = 2), predict(learner$model$model, type = "quantile", p = c(0.2, 0.8))) - learner = lrn("surv.parametric", dist = "exponential", form = "aft")$train(task) + learner = lrn("surv.parametric", dist = "exponential", form = "aft", discrete = FALSE)$train(task) p = learner$predict(task) quantile = p$distr$quantile(c(0.2, 0.8)) expect_equal(matrix(t(quantile), ncol = 2), predict(learner$model$model, type = "quantile", p = c(0.2, 0.8))) - learner = lrn("surv.parametric", dist = "gaussian", form = "tobit")$train(task) + learner = lrn("surv.parametric", dist = "gaussian", form = "tobit", discrete = FALSE)$train(task) p = learner$predict(task) quantile = p$distr$quantile(c(0.2, 0.8)) expect_equal(matrix(t(quantile), ncol = 2), predict(learner$model$model, type = "quantile", p = c(0.2, 0.8))) - learner = lrn("surv.parametric", dist = "lognormal")$train(task) + learner = lrn("surv.parametric", dist = "lognormal", discrete = FALSE)$train(task) p = learner$predict(task) quantile = p$distr$quantile(c(0.2, 0.8)) expect_equal(matrix(t(quantile), ncol = 2), @@ -99,25 +120,25 @@ test_that("cdf dist", { row_ids = 1:10 value = length(row_ids) - learner = lrn("surv.parametric", dist = "weibull", form = "aft")$train(task) + learner = lrn("surv.parametric", dist = "weibull", form = "aft", discrete = FALSE)$train(task) p = learner$predict(task, row_ids = row_ids) cdf = predict(learner$model$model, type = "quantile", p = c(0.2, 0.8))[row_ids, ] expect_equal(unname(as.matrix(p$distr$cdf(data = t(cdf)))), matrix(c(rep(0.2, value), rep(0.8, value)), byrow = TRUE, nrow = 2)) - learner = lrn("surv.parametric", dist = "exponential", form = "aft")$train(task) + learner = lrn("surv.parametric", dist = "exponential", form = "aft", discrete = FALSE)$train(task) p = learner$predict(task, row_ids = row_ids) cdf = predict(learner$model$model, type = "quantile", p = c(0.2, 0.8))[row_ids, ] expect_equal(unname(as.matrix(p$distr$cdf(data = t(cdf)))), matrix(c(rep(0.2, value), rep(0.8, value)), byrow = TRUE, nrow = 2)) - learner = lrn("surv.parametric", dist = "gaussian", form = "tobit")$train(task) + learner = lrn("surv.parametric", dist = "gaussian", form = "tobit", discrete = FALSE)$train(task) p = learner$predict(task, row_ids = row_ids) cdf = predict(learner$model$model, type = "quantile", p = c(0.2, 0.8))[row_ids, ] expect_equal(unname(as.matrix(p$distr$cdf(data = t(cdf)))), matrix(c(rep(0.2, value), rep(0.8, value)), byrow = TRUE, nrow = 2)) - learner = lrn("surv.parametric", dist = "lognormal")$train(task) + learner = lrn("surv.parametric", dist = "lognormal", discrete = FALSE)$train(task) p = learner$predict(task, row_ids = row_ids) cdf = predict(learner$model$model, type = "quantile", p = c(0.2, 0.8))[row_ids, ] expect_equal(unname(as.matrix(p$distr$cdf(data = t(cdf)))), @@ -125,18 +146,17 @@ test_that("cdf dist", { }) test_that("loglogistic", { - skip_if_not_installed("actuar") row_ids = 1:10 value = length(row_ids) - learner = lrn("surv.parametric", dist = "loglogistic")$train(task) + learner = lrn("surv.parametric", dist = "loglogistic", discrete = FALSE)$train(task) p = learner$predict(task, row_ids = row_ids) quantile = p$distr$quantile(c(0.2, 0.8)) expect_equal(matrix(t(quantile), ncol = 2), predict(learner$model$model, type = "quantile", p = c(0.2, 0.8))[row_ids, ]) - learner = lrn("surv.parametric", dist = "loglogistic")$train(task) + learner = lrn("surv.parametric", dist = "loglogistic", discrete = FALSE)$train(task) p = learner$predict(task, row_ids = row_ids) cdf = predict(learner$model$model, type = "quantile", p = c(0.2, 0.8))[row_ids, ] expect_equal(unname(as.matrix(p$distr$cdf(data = t(cdf)))), diff --git a/tests/testthat/test_survivalsvm_surv_svm.R b/tests/testthat/test_survivalsvm_surv_svm.R index 7a14b3f46..cc9144140 100644 --- a/tests/testthat/test_survivalsvm_surv_svm.R +++ b/tests/testthat/test_survivalsvm_surv_svm.R @@ -1,6 +1,6 @@ test_that("autotest", { learner = LearnerSurvSVM$new() - learner$param_set$values = list(gamma.mu = 0.1) + learner$param_set$values = list(gamma = 0.1) expect_learner(learner) result = run_autotest(learner, exclude = "feat_single", check_replicable = FALSE) expect_true(result, info = result$error)