├── .Rbuildignore ├── .editorconfig ├── .github ├── ISSUE_TEMPLATE │ ├── bug-report.yml │ └── learner-request-template.md ├── PULL_REQUEST_TEMPLATE │ ├── new_learner.md │ └── other.md ├── dependabot.yml ├── pull_request_template.md └── workflows │ ├── devcmdcheck.yml │ ├── pkgdown.yml │ └── rcmdcheck.yml ├── .gitignore ├── .ignore ├── .lintr ├── .pre-commit-config.yaml ├── DESCRIPTION ├── LICENSE ├── NAMESPACE ├── NEWS.md ├── R ├── aaa.R ├── bibentries.R ├── create_learner.R ├── encode_data_lightgbm.R ├── fn_install_learners.R ├── fn_list_mlr3learners.R ├── helpers.R ├── helpers_glmnet.R ├── helpers_rweka.R ├── helpers_xgboost.R ├── learner_BART_surv_bart.R ├── learner_C50_classif_C50.R ├── learner_CoxBoost_surv_coxboost.R ├── learner_CoxBoost_surv_cv_coxboost.R ├── learner_Cubist_regr_cubist.R ├── learner_FNN_classif_fnn.R ├── learner_FNN_regr_fnn.R ├── learner_LiblineaR_classif_liblinear.R ├── learner_LiblineaR_regr_liblinear.R ├── learner_RWeka_classif_AdaBoostM1.R ├── learner_RWeka_classif_IBk.R ├── learner_RWeka_classif_J48.R ├── learner_RWeka_classif_JRip.R ├── learner_RWeka_classif_LMT.R ├── learner_RWeka_classif_OneR.R ├── learner_RWeka_classif_PART.R ├── learner_RWeka_classif_bayes_net.R ├── learner_RWeka_classif_decision_stump.R ├── learner_RWeka_classif_decision_table.R ├── learner_RWeka_classif_kstar.R ├── learner_RWeka_classif_logistic.R ├── learner_RWeka_classif_multilayer_perceptron.R ├── learner_RWeka_classif_naive_bayes_multinomial.R ├── learner_RWeka_classif_naive_bayes_weka.R ├── learner_RWeka_classif_random_forest_weka.R ├── learner_RWeka_classif_random_tree.R ├── learner_RWeka_classif_reptree.R ├── learner_RWeka_classif_sgd.R ├── learner_RWeka_classif_simple_logistic.R ├── learner_RWeka_classif_smo.R ├── learner_RWeka_classif_voted_perceptron.R ├── learner_RWeka_regr_IBk.R ├── learner_RWeka_regr_M5Rules.R ├── learner_RWeka_regr_decision_stump.R ├── learner_RWeka_regr_decision_table.R ├── learner_RWeka_regr_gaussian_processes.R ├── learner_RWeka_regr_kstar.R ├── learner_RWeka_regr_linear_regression.R ├── learner_RWeka_regr_m5p.R ├── learner_RWeka_regr_multilayer_perceptron.R ├── learner_RWeka_regr_random_forest_weka.R ├── learner_RWeka_regr_random_tree.R ├── learner_RWeka_regr_reptree.R ├── learner_RWeka_regr_sgd.R ├── learner_RWeka_regr_simple_linear_regression.R ├── learner_RWeka_regr_smo_reg.R ├── learner_abess_classif_abess.R ├── learner_abess_regr_abess.R ├── learner_aorsf_classif_aorsf.R ├── learner_aorsf_regr_aorsf.R ├── learner_aorsf_surv_aorsf.R ├── learner_catboost_classif_catboost.R ├── learner_catboost_regr_catboost.R ├── learner_dbarts_classif_bart.R ├── learner_dbarts_regr_bart.R ├── learner_earth_classif_earth.R ├── learner_earth_regr_earth.R ├── learner_flexsurv_surv_flexible.R ├── learner_gbm_classif_gbm.R ├── learner_gbm_regr_gbm.R ├── learner_gbm_surv_gbm.R ├── learner_glmnet_surv_cv_glmnet.R ├── learner_glmnet_surv_glmnet.R ├── learner_gss_dens_spline.R ├── learner_kernlab_classif_gausspr.R ├── learner_kernlab_classif_ksvm.R ├── learner_kernlab_classif_lssvm.R ├── learner_kernlab_regr_gausspr.R ├── learner_kernlab_regr_ksvm.R ├── learner_kernlab_regr_rvm.R ├── learner_ks_dens_kde_ks.R ├── learner_lightgbm_classif_lightgbm.R ├── learner_lightgbm_regr_lightgbm.R ├── learner_lme4_classif_glmer.R ├── learner_lme4_regr_lmer.R ├── learner_locfit_dens_locfit.R ├── learner_logspline_dens_logspline.R ├── learner_mboost_classif_gamboost.R ├── learner_mboost_classif_glmboost.R ├── learner_mboost_regr_gamboost.R ├── learner_mboost_regr_glmboost.R ├── learner_mboost_surv_blackboost.R ├── learner_mboost_surv_gamboost.R ├── learner_mboost_surv_glmboost.R ├── learner_mboost_surv_mboost.R ├── learner_mda_regr_mars.R ├── learner_mgcv_classif_gam.R ├── learner_mgcv_regr_gam.R ├── learner_np_dens_mixed.R ├── learner_partykit_classif_cforest.R ├── learner_partykit_classif_ctree.R ├── learner_partykit_classif_mob.R ├── learner_partykit_regr_cforest.R ├── learner_partykit_regr_ctree.R ├── learner_partykit_regr_mob.R ├── learner_partykit_surv_cforest.R ├── learner_partykit_surv_ctree.R ├── learner_penalized_surv_penalized.R ├── learner_pendensity_dens_pen.R ├── learner_plugdensity_dens_plug.R ├── learner_prioritylasso_classif_priority_lasso.R ├── learner_prioritylasso_regr_priority_lasso.R ├── learner_prioritylasso_surv_priority_lasso.R ├── learner_qgam_regr_mqgam.R ├── learner_qgam_regr_qgam.R ├── learner_randomForestSRC_classif_imbalanced_rfsrc.R ├── learner_randomForestSRC_classif_rfsrc.R ├── learner_randomForestSRC_regr_rfsrc.R ├── learner_randomForestSRC_surv_rfsrc.R ├── learner_randomForest_classif_randomForest.R ├── learner_randomForest_regr_randomForest.R ├── learner_randomPlantedForest_classif_rpf.R ├── learner_randomPlantedForest_regr_rpf.R ├── learner_ranger_surv_ranger.R ├── learner_rsm_regr_rsm.R ├── learner_sm_dens_nonpar.R ├── learner_stats_regr_glm.R ├── learner_survival_surv_nelson.R ├── learner_survivalmodels_surv_akritas.R ├── learner_survivalmodels_surv_coxtime.R ├── learner_survivalmodels_surv_deephit.R ├── learner_survivalmodels_surv_deepsurv.R ├── learner_survivalmodels_surv_dnnsurv.R ├── learner_survivalmodels_surv_loghaz.R ├── learner_survivalmodels_surv_parametric.R ├── learner_survivalmodels_surv_pchazard.R ├── learner_survivalsvm_surv_svm.R ├── learner_tabpfn_classif_tabpfn.R ├── learner_tabpfn_regr_tabpfn.R ├── learner_xgboost_surv_xgboost_aft.R ├── learner_xgboost_surv_xgboost_cox.R ├── train_cforest.R └── zzz.R ├── README.Rmd ├── README.md ├── attic └── fn_install_catboost.R ├── inst └── templates │ ├── learner_template.R │ ├── param_test_template.R │ └── test_template.R ├── man-roxygen ├── example.R ├── install_coxboost.R ├── install_survivalmodels.R ├── learner.R ├── note_xgboost.R ├── section_early_stopping.R ├── section_formula.R ├── sections_tabpfn.R ├── seealso_learner.R └── simple_example.R ├── man ├── create_learner.Rd ├── figures │ └── logo_navbar.png ├── install_learners.Rd ├── list_mlr3learners.Rd ├── mlr3extralearners-package.Rd ├── mlr_learners_classif.AdaBoostM1.Rd ├── mlr_learners_classif.C50.Rd ├── mlr_learners_classif.IBk.Rd ├── mlr_learners_classif.J48.Rd ├── mlr_learners_classif.JRip.Rd ├── mlr_learners_classif.LMT.Rd ├── mlr_learners_classif.OneR.Rd ├── mlr_learners_classif.PART.Rd ├── mlr_learners_classif.abess.Rd ├── mlr_learners_classif.aorsf.Rd ├── mlr_learners_classif.bart.Rd ├── mlr_learners_classif.bayes_net.Rd ├── mlr_learners_classif.catboost.Rd ├── mlr_learners_classif.cforest.Rd ├── mlr_learners_classif.ctree.Rd ├── mlr_learners_classif.decision_stump.Rd ├── mlr_learners_classif.decision_table.Rd ├── mlr_learners_classif.earth.Rd ├── mlr_learners_classif.fnn.Rd ├── mlr_learners_classif.gam.Rd ├── mlr_learners_classif.gamboost.Rd ├── mlr_learners_classif.gausspr.Rd ├── mlr_learners_classif.gbm.Rd ├── mlr_learners_classif.glmboost.Rd ├── mlr_learners_classif.glmer.Rd ├── mlr_learners_classif.imbalanced_rfsrc.Rd ├── mlr_learners_classif.kstar.Rd ├── mlr_learners_classif.ksvm.Rd ├── mlr_learners_classif.liblinear.Rd ├── mlr_learners_classif.lightgbm.Rd ├── mlr_learners_classif.logistic.Rd ├── mlr_learners_classif.lssvm.Rd ├── mlr_learners_classif.mob.Rd ├── mlr_learners_classif.multilayer_perceptron.Rd ├── mlr_learners_classif.naive_bayes_multinomial.Rd ├── mlr_learners_classif.naive_bayes_weka.Rd ├── mlr_learners_classif.priority_lasso.Rd ├── mlr_learners_classif.randomForest.Rd ├── mlr_learners_classif.random_forest_weka.Rd ├── mlr_learners_classif.random_tree.Rd ├── mlr_learners_classif.reptree.Rd ├── mlr_learners_classif.rfsrc.Rd ├── mlr_learners_classif.rpf.Rd ├── mlr_learners_classif.sgd.Rd ├── mlr_learners_classif.simple_logistic.Rd ├── mlr_learners_classif.smo.Rd ├── mlr_learners_classif.tabpfn.Rd ├── mlr_learners_classif.voted_perceptron.Rd ├── mlr_learners_dens.kde_ks.Rd ├── mlr_learners_dens.locfit.Rd ├── mlr_learners_dens.logspline.Rd ├── mlr_learners_dens.mixed.Rd ├── mlr_learners_dens.nonpar.Rd ├── mlr_learners_dens.pen.Rd ├── mlr_learners_dens.plug.Rd ├── mlr_learners_dens.spline.Rd ├── mlr_learners_regr.IBk.Rd ├── mlr_learners_regr.M5Rules.Rd ├── mlr_learners_regr.abess.Rd ├── mlr_learners_regr.aorsf.Rd ├── mlr_learners_regr.bart.Rd ├── mlr_learners_regr.catboost.Rd ├── mlr_learners_regr.cforest.Rd ├── mlr_learners_regr.ctree.Rd ├── mlr_learners_regr.cubist.Rd ├── mlr_learners_regr.decision_stump.Rd ├── mlr_learners_regr.decision_table.Rd ├── mlr_learners_regr.earth.Rd ├── mlr_learners_regr.fnn.Rd ├── mlr_learners_regr.gam.Rd ├── mlr_learners_regr.gamboost.Rd ├── mlr_learners_regr.gaussian_processes.Rd ├── mlr_learners_regr.gausspr.Rd ├── mlr_learners_regr.gbm.Rd ├── mlr_learners_regr.glm.Rd ├── mlr_learners_regr.glmboost.Rd ├── mlr_learners_regr.kstar.Rd ├── mlr_learners_regr.ksvm.Rd ├── mlr_learners_regr.liblinear.Rd ├── mlr_learners_regr.lightgbm.Rd ├── mlr_learners_regr.linear_regression.Rd ├── mlr_learners_regr.lmer.Rd ├── mlr_learners_regr.m5p.Rd ├── mlr_learners_regr.mars.Rd ├── mlr_learners_regr.mob.Rd ├── mlr_learners_regr.mqgam.Rd ├── mlr_learners_regr.multilayer_perceptron.Rd ├── mlr_learners_regr.priority_lasso.Rd ├── mlr_learners_regr.qgam.Rd ├── mlr_learners_regr.randomForest.Rd ├── mlr_learners_regr.random_forest_weka.Rd ├── mlr_learners_regr.random_tree.Rd ├── mlr_learners_regr.reptree.Rd ├── mlr_learners_regr.rfsrc.Rd ├── mlr_learners_regr.rpf.Rd ├── mlr_learners_regr.rsm.Rd ├── mlr_learners_regr.rvm.Rd ├── mlr_learners_regr.sgd.Rd ├── mlr_learners_regr.simple_linear_regression.Rd ├── mlr_learners_regr.smo_reg.Rd ├── mlr_learners_regr.tabpfn.Rd ├── mlr_learners_surv.akritas.Rd ├── mlr_learners_surv.aorsf.Rd ├── mlr_learners_surv.bart.Rd ├── mlr_learners_surv.blackboost.Rd ├── mlr_learners_surv.cforest.Rd ├── mlr_learners_surv.coxboost.Rd ├── mlr_learners_surv.coxtime.Rd ├── mlr_learners_surv.ctree.Rd ├── mlr_learners_surv.cv_coxboost.Rd ├── mlr_learners_surv.cv_glmnet.Rd ├── mlr_learners_surv.deephit.Rd ├── mlr_learners_surv.deepsurv.Rd ├── mlr_learners_surv.dnnsurv.Rd ├── mlr_learners_surv.flexible.Rd ├── mlr_learners_surv.gamboost.Rd ├── mlr_learners_surv.gbm.Rd ├── mlr_learners_surv.glmboost.Rd ├── mlr_learners_surv.glmnet.Rd ├── mlr_learners_surv.loghaz.Rd ├── mlr_learners_surv.mboost.Rd ├── mlr_learners_surv.nelson.Rd ├── mlr_learners_surv.parametric.Rd ├── mlr_learners_surv.pchazard.Rd ├── mlr_learners_surv.penalized.Rd ├── mlr_learners_surv.priority_lasso.Rd ├── mlr_learners_surv.ranger.Rd ├── mlr_learners_surv.rfsrc.Rd ├── mlr_learners_surv.svm.Rd ├── mlr_learners_surv.xgboost.aft.Rd ├── mlr_learners_surv.xgboost.cox.Rd └── reexports.Rd ├── mlr3extralearners.Rproj ├── pkgdown ├── _pkgdown.yml └── favicon │ ├── apple-touch-icon-120x120.png │ ├── apple-touch-icon-152x152.png │ ├── apple-touch-icon-180x180.png │ ├── apple-touch-icon-60x60.png │ ├── apple-touch-icon-76x76.png │ ├── apple-touch-icon.png │ ├── favicon-16x16.png │ ├── favicon-32x32.png │ └── favicon.ico ├── tests ├── testthat.R └── testthat │ ├── helper.R │ ├── test_BART_surv_bart.R │ ├── test_C50_classif_C50.R │ ├── test_CoxBoost_surv_coxboost.R │ ├── test_CoxBoost_surv_cv_coxboost.R │ ├── test_Cubist_regr_cubist.R │ ├── test_FNN_classif_fnn.R │ ├── test_FNN_regr_fnn.R │ ├── test_LiblineaR_classif_liblinear.R │ ├── test_LiblineaR_regr_liblinear.R │ ├── test_RWeka_classif_AdaBoostM1.R │ ├── test_RWeka_classif_IBk.R │ ├── test_RWeka_classif_J48.R │ ├── test_RWeka_classif_JRip.R │ ├── test_RWeka_classif_LMT.R │ ├── test_RWeka_classif_OneR.R │ ├── test_RWeka_classif_PART.R │ ├── test_RWeka_classif_bayes_net.R │ ├── test_RWeka_classif_decision_stump.R │ ├── test_RWeka_classif_decision_table.R │ ├── test_RWeka_classif_kstar.R │ ├── test_RWeka_classif_logistic.R │ ├── test_RWeka_classif_multilayer_perceptron.R │ ├── test_RWeka_classif_naive_bayes_multinomial.R │ ├── test_RWeka_classif_naive_bayes_weka.R │ ├── test_RWeka_classif_random_forest_weka.R │ ├── test_RWeka_classif_random_tree.R │ ├── test_RWeka_classif_reptree.R │ ├── test_RWeka_classif_sgd.R │ ├── test_RWeka_classif_simple_logistic.R │ ├── test_RWeka_classif_smo.R │ ├── test_RWeka_classif_voted_perceptron.R │ ├── test_RWeka_regr_IBk.R │ ├── test_RWeka_regr_M5Rules.R │ ├── test_RWeka_regr_decision_stump.R │ ├── test_RWeka_regr_decision_table.R │ ├── test_RWeka_regr_gaussian_processes.R │ ├── test_RWeka_regr_kstar.R │ ├── test_RWeka_regr_linear_regression.R │ ├── test_RWeka_regr_m5p.R │ ├── test_RWeka_regr_multilayer_perceptron.R │ ├── test_RWeka_regr_random_forest_weka.R │ ├── test_RWeka_regr_random_tree.R │ ├── test_RWeka_regr_reptree.R │ ├── test_RWeka_regr_sgd.R │ ├── test_RWeka_regr_simple_linear_regression.R │ ├── test_RWeka_regr_smo_reg.R │ ├── test_abess_classif_abess.R │ ├── test_abess_regr_abess.R │ ├── test_aorsf_classif_aorsf.R │ ├── test_aorsf_regr_aorsf.R │ ├── test_aorsf_surv_aorsf.R │ ├── test_catboost_classif_catboost.R │ ├── test_catboost_regr_catboost.R │ ├── test_create_learner.R │ ├── test_dbarts_classif_bart.R │ ├── test_dbarts_regr_bart.R │ ├── test_earth_classif_earth.R │ ├── test_earth_regr_earth.R │ ├── test_encode_data_lightgbm.R │ ├── test_flexsurv_surv_flexible.R │ ├── test_gbm_classif_gbm.R │ ├── test_gbm_regr_gbm.R │ ├── test_gbm_surv_gbm.R │ ├── test_glmnet_surv_cv_glmnet.R │ ├── test_glmnet_surv_glmnet.R │ ├── test_gss_dens_spline.R │ ├── test_kernlab_classif_gausspr.R │ ├── test_kernlab_classif_ksvm.R │ ├── test_kernlab_classif_lssvm.R │ ├── test_kernlab_regr_gausspr.R │ ├── test_kernlab_regr_ksvm.R │ ├── test_kernlab_regr_rvm.R │ ├── test_ks_dens_kde_ks.R │ ├── test_lightgbm_classif_lightgbm.R │ ├── test_lightgbm_regr_lightgbm.R │ ├── test_lme4_classif_glmer.R │ ├── test_lme4_regr_lmer.R │ ├── test_locfit_dens_locfit.R │ ├── test_logspline_dens_logspline.R │ ├── test_mboost_classif_gamboost.R │ ├── test_mboost_classif_glmboost.R │ ├── test_mboost_regr_gamboost.R │ ├── test_mboost_regr_glmboost.R │ ├── test_mboost_surv_blackboost.R │ ├── test_mboost_surv_gamboost.R │ ├── test_mboost_surv_glmboost.R │ ├── test_mboost_surv_mboost.R │ ├── test_mda_regr_mars.R │ ├── test_mgcv_classif_gam.R │ ├── test_mgcv_regr_gam.R │ ├── test_np_dens_mixed.R │ ├── test_paramtest_BART_surv_bart.R │ ├── test_paramtest_C50_classif_C50.R │ ├── test_paramtest_CoxBoost_surv_coxboost.R │ ├── test_paramtest_CoxBoost_surv_cv_coxboost.R │ ├── test_paramtest_Cubist_regr_cubist.R │ ├── test_paramtest_FNN_classif_fnn.R │ ├── test_paramtest_FNN_regr_fnn.R │ ├── test_paramtest_LiblineaR_classif_liblinear.R │ ├── test_paramtest_LiblineaR_regr_liblinear.R │ ├── test_paramtest_RWeka_classif_AdaBoostM1.R │ ├── test_paramtest_RWeka_classif_IBk.R │ ├── test_paramtest_RWeka_classif_J48.R │ ├── test_paramtest_RWeka_classif_JRip.R │ ├── test_paramtest_RWeka_classif_LMT.R │ ├── test_paramtest_RWeka_classif_OneR.R │ ├── test_paramtest_RWeka_classif_PART.R │ ├── test_paramtest_RWeka_classif_bayes_net.R │ ├── test_paramtest_RWeka_classif_decision_stump.R │ ├── test_paramtest_RWeka_classif_decision_table.R │ ├── test_paramtest_RWeka_classif_kstar.R │ ├── test_paramtest_RWeka_classif_logistic.R │ ├── test_paramtest_RWeka_classif_multilayer_perceptron.R │ ├── test_paramtest_RWeka_classif_naive_bayes_multinomial.R │ ├── test_paramtest_RWeka_classif_naive_bayes_weka.R │ ├── test_paramtest_RWeka_classif_random_forest_weka.R │ ├── test_paramtest_RWeka_classif_random_tree.R │ ├── test_paramtest_RWeka_classif_reptree.R │ ├── test_paramtest_RWeka_classif_sgd.R │ ├── test_paramtest_RWeka_classif_simple_logistic.R │ ├── test_paramtest_RWeka_classif_smo.R │ ├── test_paramtest_RWeka_classif_voted_perceptron.R │ ├── test_paramtest_RWeka_regr_IBk.R │ ├── test_paramtest_RWeka_regr_M5Rules.R │ ├── test_paramtest_RWeka_regr_decision_stump.R │ ├── test_paramtest_RWeka_regr_decision_table.R │ ├── test_paramtest_RWeka_regr_gaussian_processes.R │ ├── test_paramtest_RWeka_regr_kstar.R │ ├── test_paramtest_RWeka_regr_linear_regression.R │ ├── test_paramtest_RWeka_regr_m5p.R │ ├── test_paramtest_RWeka_regr_multilayer_perceptron.R │ ├── test_paramtest_RWeka_regr_random_forest_weka.R │ ├── test_paramtest_RWeka_regr_random_tree.R │ ├── test_paramtest_RWeka_regr_reptree.R │ ├── test_paramtest_RWeka_regr_sgd.R │ ├── test_paramtest_RWeka_regr_simple_linear_regression.R │ ├── test_paramtest_RWeka_regr_smo_reg.R │ ├── test_paramtest_abess_classif_abess.R │ ├── test_paramtest_abess_regr_abess.R │ ├── test_paramtest_aorsf_classif_aorsf.R │ ├── test_paramtest_aorsf_regr_aorsf.R │ ├── test_paramtest_aorsf_surv_aorsf.R │ ├── test_paramtest_catboost_classif_catboost.R │ ├── test_paramtest_catboost_regr_catboost.R │ ├── test_paramtest_dbarts_classif_bart.R │ ├── test_paramtest_dbarts_regr_bart.R │ ├── test_paramtest_earth_classif_earth.R │ ├── test_paramtest_earth_regr_earth.R │ ├── test_paramtest_flexsurv_surv_flexible.R │ ├── test_paramtest_gbm_classif_gbm.R │ ├── test_paramtest_gbm_regr_gbm.R │ ├── test_paramtest_gbm_surv_gbm.R │ ├── test_paramtest_glmnet_surv_cv_glmnet.R │ ├── test_paramtest_glmnet_surv_glmnet.R │ ├── test_paramtest_gss_dens_spline.R │ ├── test_paramtest_kernlab_classif_gausspr.R │ ├── test_paramtest_kernlab_classif_ksvm.R │ ├── test_paramtest_kernlab_classif_lssvm.R │ ├── test_paramtest_kernlab_regr_gausspr.R │ ├── test_paramtest_kernlab_regr_ksvm.R │ ├── test_paramtest_kernlab_regr_rvm.R │ ├── test_paramtest_ks_dens_kde_ks.R │ ├── test_paramtest_lightgbm_classif_lightgbm.R │ ├── test_paramtest_lightgbm_regr_lightgbm.R │ ├── test_paramtest_lme4_classif_glmer.R │ ├── test_paramtest_lme4_regr_lmer.R │ ├── test_paramtest_locfit_dens_locfit.R │ ├── test_paramtest_logspline_dens_logspline.R │ ├── test_paramtest_mboost_classif_gamboost.R │ ├── test_paramtest_mboost_classif_glmboost.R │ ├── test_paramtest_mboost_regr_gamboost.R │ ├── test_paramtest_mboost_regr_glmboost.R │ ├── test_paramtest_mboost_surv_blackboost.R │ ├── test_paramtest_mboost_surv_gamboost.R │ ├── test_paramtest_mboost_surv_glmboost.R │ ├── test_paramtest_mboost_surv_mboost.R │ ├── test_paramtest_mda_regr_mars.R │ ├── test_paramtest_mgcv_classif_gam.R │ ├── test_paramtest_mgcv_regr_gam.R │ ├── test_paramtest_np_dens_mixed.R │ ├── test_paramtest_partykit_classif_cforest.R │ ├── test_paramtest_partykit_classif_ctree.R │ ├── test_paramtest_partykit_classif_mob.R │ ├── test_paramtest_partykit_regr_cforest.R │ ├── test_paramtest_partykit_regr_ctree.R │ ├── test_paramtest_partykit_regr_mob.R │ ├── test_paramtest_partykit_surv_cforest.R │ ├── test_paramtest_partykit_surv_ctree.R │ ├── test_paramtest_penalized_surv_penalized.R │ ├── test_paramtest_pendensity_dens_pen.R │ ├── test_paramtest_plugdensity_dens_plug.R │ ├── test_paramtest_prioritylasso_classif_priority_lasso.R │ ├── test_paramtest_prioritylasso_regr_priority_lasso.R │ ├── test_paramtest_prioritylasso_surv_priority_lasso.R │ ├── test_paramtest_qgam_regr_mqgam.R │ ├── test_paramtest_qgam_regr_qgam.R │ ├── test_paramtest_randomForestSRC_classif_imbalanced_rfsrc.R │ ├── test_paramtest_randomForestSRC_classif_rfsrc.R │ ├── test_paramtest_randomForestSRC_regr_rfsrc.R │ ├── test_paramtest_randomForestSRC_surv_rfsrc.R │ ├── test_paramtest_randomForest_classif_randomForest.R │ ├── test_paramtest_randomForest_regr_randomForest.R │ ├── test_paramtest_randomPlantedForest_classif_rpf.R │ ├── test_paramtest_randomPlantedForest_regr_rpf.R │ ├── test_paramtest_ranger_surv_ranger.R │ ├── test_paramtest_rsm_regr_rsm.R │ ├── test_paramtest_sm_dens_nonpar.R │ ├── test_paramtest_stats_regr_glm.R │ ├── test_paramtest_survival_surv_nelson.R │ ├── test_paramtest_survivalmodels_surv_akritas.R │ ├── test_paramtest_survivalmodels_surv_coxtime.R │ ├── test_paramtest_survivalmodels_surv_deephit.R │ ├── test_paramtest_survivalmodels_surv_deepsurv.R │ ├── test_paramtest_survivalmodels_surv_dnnsurv.R │ ├── test_paramtest_survivalmodels_surv_loghaz.R │ ├── test_paramtest_survivalmodels_surv_parametric.R │ ├── test_paramtest_survivalmodels_surv_pchazard.R │ ├── test_paramtest_survivalsvm_surv_svm.R │ ├── test_paramtest_xgboost_surv_xgboost.R │ ├── test_partykit_classif_cforest.R │ ├── test_partykit_classif_ctree.R │ ├── test_partykit_classif_mob.R │ ├── test_partykit_regr_cforest.R │ ├── test_partykit_regr_ctree.R │ ├── test_partykit_regr_mob.R │ ├── test_partykit_surv_cforest.R │ ├── test_partykit_surv_ctree.R │ ├── test_penalized_surv_penalized.R │ ├── test_pendensity_dens_pen.R │ ├── test_plugdensity_dens_plug.R │ ├── test_prioritylasso_classif_priority_lasso.R │ ├── test_prioritylasso_regr_priority_lasso.R │ ├── test_prioritylasso_surv_priority_lasso.R │ ├── test_qgam_regr_mqgam.R │ ├── test_qgam_regr_qgam.R │ ├── test_randomForestSRC_classif_imbalanced_rfsrc.R │ ├── test_randomForestSRC_classif_rfsrc.R │ ├── test_randomForestSRC_regr_rfsrc.R │ ├── test_randomForestSRC_surv_rfsrc.R │ ├── test_randomForest_classif_randomForest.R │ ├── test_randomForest_regr_randomForest.R │ ├── test_randomPlantedForest_classif_rpf.R │ ├── test_randomPlantedForest_regr_rpf.R │ ├── test_ranger_surv_ranger.R │ ├── test_rsm_regr_rsm.R │ ├── test_rweka_helper.R │ ├── test_sm_dens_nonpar.R │ ├── test_stats_regr_glm.R │ ├── test_survival_surv_nelson.R │ ├── test_survivalmodels_surv_akritas.R │ ├── test_survivalmodels_surv_coxtime.R │ ├── test_survivalmodels_surv_deephit.R │ ├── test_survivalmodels_surv_deepsurv.R │ ├── test_survivalmodels_surv_dnnsurv.R │ ├── test_survivalmodels_surv_loghaz.R │ ├── test_survivalmodels_surv_parametric.R │ ├── test_survivalmodels_surv_pchazard.R │ ├── test_survivalsvm_surv_svm.R │ ├── test_tabpfn_classif_tabpfn.R │ ├── test_tabpfn_regr_tabpfn.R │ └── test_xgboost_surv_xgboost.R └── vignettes ├── .gitignore ├── articles ├── learner_status.Rmd └── list_learners.Rmd ├── common_issues.Rmd └── extending.Rmd /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^LICENSE$ 2 | ^tic\.R$ 3 | ^appveyor\.yml$ 4 | .ignore 5 | .editorconfig 6 | .gitignore 7 | ^\.travis\.yml$ 8 | ^.*\.Rproj$ 9 | ^\.Rproj\.user$ 10 | ^man-roxygen$ 11 | ^attic$ 12 | ^docs$ 13 | ^pkgdown$ 14 | ^renv$ 15 | ^renv\.lock$ 16 | ^\.ccache$ 17 | ^\.github$ 18 | ^clang-.* 19 | ^\.lintr$ 20 | ^\.vscode$ 21 | ^build\_learner\_table\.R$ 22 | ^README\.Rmd$ 23 | vignettes/learners 24 | ^.pre-commit-config.yaml 25 | ^vignettes/articles$ 26 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # See http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | insert_final_newline = true 8 | indent_style = space 9 | trim_trailing_whitespace = true 10 | 11 | [*.{r,R,md,Rmd}] 12 | indent_size = 2 13 | 14 | [*.{c,h}] 15 | indent_size = 4 16 | 17 | [*.{cpp,hpp}] 18 | indent_size = 4 19 | 20 | [{NEWS.md,DESCRIPTION,LICENSE}] 21 | max_line_length = 80 22 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/learner-request-template.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Learner request 3 | about: Used to request or discuss new learners 4 | title: "[LRNRQ] Add from package " 5 | labels: "Learner Status: Request" 6 | assignees: '' 7 | 8 | --- 9 | 10 | ### Algorithm 11 | 12 | 13 | 14 | ### Package 15 | 16 | 17 | 18 | ### Supported types 19 | 20 | * [ ] classif 21 | * [ ] clust 22 | * [ ] dens 23 | * [ ] regr 24 | * [ ] surv 25 | 26 | ### I have checked that this is not already implemented in 27 | 28 | * [ ] mlr3 29 | * [ ] mlr3learners 30 | * [ ] mlr3extralearners 31 | * [ ] Other core packages (e.g. mlr3proba, mlr3keras) 32 | 33 | ### Why do I think this is a useful learner? 34 | 35 | ### Further Optional Comments 36 | 37 | (e.g. if this algorithm is already implemented under a different learner then please explain why this additional implementation is useful) 38 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE/new_learner.md: -------------------------------------------------------------------------------- 1 | Thank you for contributing a learner to the mlr3 ecosystem. 2 | Please make sure that: 3 | 4 | - [ ] The added learner(s) are sufficiently tested 5 | - [ ] All the CI tests are passing (including the CodeFactor) 6 | - [ ] You ran `devtools::document()` 7 | - [ ] You updated the `NEWS.md` field to include the addition of the learner 8 | - [ ] You did not modify anything **not** related to the new learner 9 | - [ ] You are listed as a contributor in the `DESCRIPTION` of the R package 10 | 11 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE/other.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mlr-org/mlr3extralearners/80f4c3dd54e96f5dfef2e75662e5ce3b0e3d2b0b/.github/PULL_REQUEST_TEMPLATE/other.md -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "github-actions" 4 | directory: "/" 5 | schedule: 6 | interval: "weekly" 7 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | Please go the the `Preview` tab and select the appropriate sub-template: 2 | 3 | * [New Learner](?expand=1&template=new_learner.md) 4 | * [Other](?expand=1&template=other.md) 5 | -------------------------------------------------------------------------------- /.github/workflows/pkgdown.yml: -------------------------------------------------------------------------------- 1 | # pkgdown workflow of the mlr3 ecosystem v0.1.0 2 | # https://github.com/mlr-org/actions 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | branches: 9 | - main 10 | release: 11 | types: 12 | - published 13 | workflow_dispatch: 14 | 15 | name: pkgdown 16 | 17 | jobs: 18 | pkgdown: 19 | runs-on: ubuntu-latest 20 | 21 | concurrency: 22 | group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} 23 | env: 24 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 25 | steps: 26 | - uses: actions/checkout@v4 27 | 28 | - uses: r-lib/actions/setup-pandoc@v2 29 | 30 | - uses: r-lib/actions/setup-r@v2 31 | 32 | - uses: r-lib/actions/setup-r-dependencies@v2 33 | with: 34 | extra-packages: any::pkgdown, local::. 35 | needs: website 36 | 37 | - name: Install template 38 | run: pak::pkg_install("mlr-org/mlr3pkgdowntemplate") 39 | shell: Rscript {0} 40 | 41 | - name: Build site 42 | run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) 43 | shell: Rscript {0} 44 | 45 | - name: Deploy 46 | if: github.event_name != 'pull_request' 47 | uses: JamesIves/github-pages-deploy-action@v4.7.3 48 | with: 49 | clean: false 50 | branch: gh-pages 51 | folder: docs 52 | -------------------------------------------------------------------------------- /.ignore: -------------------------------------------------------------------------------- 1 | man/ 2 | attic/ 3 | pkgdown/ 4 | revdep/ 5 | docs/ 6 | -------------------------------------------------------------------------------- /.lintr: -------------------------------------------------------------------------------- 1 | linters: linters_with_defaults( 2 | # lintr defaults: https://github.com/jimhester/lintr#available-linters 3 | # the following setup changes/removes certain linters 4 | assignment_linter = NULL, # do not force using <- for assignments 5 | object_name_linter = object_name_linter(c("snake_case", "CamelCase")), # only allow snake case and camel case object names 6 | cyclocomp_linter = NULL, # do not check function complexity 7 | commented_code_linter = NULL, # allow code in comments 8 | todo_comment_linter = NULL, # allow todo in comments 9 | line_length_linter = line_length_linter(120), 10 | object_length_linter = object_length_linter(40) 11 | ) 12 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | # All available hooks: https://pre-commit.com/hooks.html 2 | repos: 3 | - repo: https://github.com/lorenzwalthert/precommit 4 | rev: v0.1.2 5 | hooks: 6 | # any R project 7 | - id: style-files 8 | args: [--style_pkg=styler.mlr, --style_fun=mlr_style] 9 | exclude: ^(man-roxygen/|templates/) 10 | # additional_dependencies: mlr-org/styler.mlr 11 | - id: lintr 12 | exclude: ^(man-roxygen/|templates/) 13 | 14 | - id: parsable-R 15 | exclude: ^templates/ 16 | - id: no-browser-statement 17 | exclude: ^templates/ 18 | 19 | - id: readme-rmd-rendered 20 | # R package development 21 | - id: use-tidy-description 22 | - id: deps-in-desc 23 | exclude: ^(templates/|R/learner_catboost_regr_catboost.R|R/learner_catboost_classif_catboost.R|tests/testthat/) 24 | - repo: https://github.com/pre-commit/pre-commit-hooks 25 | rev: v3.1.0 26 | hooks: 27 | - id: check-added-large-files 28 | args: ['--maxkb=200'] 29 | -------------------------------------------------------------------------------- /R/aaa.R: -------------------------------------------------------------------------------- 1 | # clearly this should be a Dictionary but there's a weird bug that leads to objects 2 | # being handled wrong and not cloned properly when loaded from dictionary in `mlr3::lrn` 3 | .extralrns_dict = R6Class(".extralrns_dict", 4 | public = list( 5 | lrns = list(), 6 | add = function(key, learn) { 7 | assert_character(key, len = 1) 8 | lst = list(key = learn) 9 | names(lst) = key 10 | self$lrns = insert_named(self$lrns, lst) 11 | } 12 | ) 13 | )$new() 14 | -------------------------------------------------------------------------------- /R/encode_data_lightgbm.R: -------------------------------------------------------------------------------- 1 | # For lightgbm, we internally convert the factors and logicals to integers, so that the learner 2 | # can be more easily used. Th 3 | 4 | encode_lightgbm_train = function(task) { 5 | dat = task$data(cols = task$feature_names) 6 | encode_lightgbm(dat, task) 7 | } 8 | 9 | # this does the same as the encode_lightgbm_train but checks that the levels did not permute 10 | # or a new level was added or a level was removed 11 | encode_lightgbm_predict = function(task, data_prototype, self) { 12 | factor_columns = task$feature_types$id[task$feature_types$type == "factor"] 13 | 14 | dat = ordered_features(task, self) 15 | if (!is.null(data_prototype)) { 16 | # this happens when calling the workhorse, in which case this is anyway not a problem 17 | walk( 18 | factor_columns, 19 | function(nm) { 20 | ok = all.equal(levels(dat[[nm]]), levels(data_prototype[[nm]])) 21 | if (is.character(ok)) { 22 | stopf("There is a mismatch with the factor levels of the training phase.") 23 | } 24 | } 25 | ) 26 | 27 | } 28 | 29 | encode_lightgbm(dat, task) 30 | } 31 | 32 | encode_lightgbm = function(data, task) { 33 | categorical_feature = task$feature_types$id[task$feature_types$type %in% c("factor", "logical")] 34 | 35 | X = data.matrix(data) 36 | 37 | return(list(X = X, categorical_feature = categorical_feature)) 38 | } 39 | -------------------------------------------------------------------------------- /R/helpers_xgboost.R: -------------------------------------------------------------------------------- 1 | # helper function to construct an `xgb.DMatrix` object 2 | # that has both features and target (label) data 3 | get_xgb_mat = function(task, objective, private, row_ids = NULL) { 4 | # use all task rows if `rows_ids` is not specified 5 | if (is.null(row_ids)) row_ids = task$row_ids 6 | 7 | data = task$data(rows = row_ids, cols = task$feature_names) 8 | truth = task$truth(rows = row_ids) 9 | times = truth[, 1] 10 | status = truth[, 2] 11 | 12 | if (objective == "survival:cox") { # Cox 13 | # censored => negative times, dead/event => positive times 14 | times[status != 1] = -1L * times[status != 1] 15 | data = xgboost::xgb.DMatrix( 16 | data = as_numeric_matrix(data), 17 | label = times 18 | ) 19 | } else { # AFT 20 | y_lower_bound = y_upper_bound = times 21 | y_upper_bound[status == 0] = Inf 22 | 23 | data = xgboost::xgb.DMatrix(as_numeric_matrix(data)) 24 | xgboost::setinfo(data, "label_lower_bound", y_lower_bound) 25 | xgboost::setinfo(data, "label_upper_bound", y_upper_bound) 26 | } 27 | 28 | xgboost::setinfo(data, "weight", private$.get_weights(task)) 29 | 30 | data 31 | } 32 | 33 | # return vector of importance scores given an `xgb.Booster` model 34 | xgb_imp = function(model) { 35 | if (is.null(model)) { 36 | stopf("No model stored") 37 | } 38 | 39 | imp = xgboost::xgb.importance(model = model) 40 | set_names(imp$Gain, imp$Feature) 41 | } 42 | -------------------------------------------------------------------------------- /R/train_cforest.R: -------------------------------------------------------------------------------- 1 | train_cforest = function(self, task) { 2 | # explanation for the argument assignment 3 | # the cforest function has control = ctree_control(teststat = "quad", ...) 4 | # as default argument, if we simply pass all arguments to ... (including teststat), 5 | # ctree_control gets potentially multiple arguments for teststat which leads to an error. 6 | # Because of that the ... have to be manually passed via ctree_control. 7 | # However the control-args "mtry", "applyfun" and "cores" are explicitly mentioned as 8 | # arguments of cforest and can therefore not be set 9 | pars = self$param_set$get_values(tags = "train") 10 | pars = convert_ratio(pars, "mtry", "mtryratio", length(task$feature_names)) 11 | pars_control = pars[which(names(pars) %in% 12 | setdiff(formalArgs(partykit::ctree_control), 13 | c("mtry", "applyfun", "cores") 14 | ))] # see ctree_control 15 | pars = pars[names(pars) %nin% 16 | c("replace", "fraction", names(pars_control))] 17 | control = invoke(partykit::ctree_control, .args = pars_control) 18 | perturb = list( 19 | replace = self$param_set$values$replace %??% FALSE, 20 | fraction = self$param_set$values$fraction %??% 0.632 21 | ) 22 | 23 | invoke(partykit::cforest, 24 | formula = task$formula(), 25 | data = task$data(), 26 | weights = self$.__enclos_env__$private$.get_weights(task), # weights are handled here 27 | # FIXME: strata handling 28 | control = control, 29 | perturb = perturb, 30 | .args = pars 31 | ) 32 | 33 | } 34 | -------------------------------------------------------------------------------- /R/zzz.R: -------------------------------------------------------------------------------- 1 | #' @import checkmate 2 | #' @import paradox 3 | #' @import mlr3misc 4 | #' @importFrom R6 R6Class 5 | #' @importFrom mlr3 mlr_learners LearnerClassif LearnerRegr lrn lrns marshal_model unmarshal_model 6 | #' @importFrom stats predict na.omit setNames formula as.formula 7 | #' @importFrom data.table := 8 | #' @importFrom methods formalArgs getMethod 9 | #' @importFrom utils getFromNamespace packageVersion capture.output 10 | "_PACKAGE" 11 | 12 | utils::globalVariables(c("name", "id", "mlr3_package", "required_packages", ".SD", "S", "K", "calibrator")) 13 | 14 | #' @export 15 | mlr3::lrn 16 | 17 | #' @export 18 | mlr3::lrns 19 | 20 | # nocov start 21 | register_mlr3 = function(libname, pkgname) { 22 | # get mlr_learners dictionary from the mlr3 namespace 23 | x = utils::getFromNamespace("mlr_learners", ns = "mlr3") 24 | # this prevents a very long list of extra learners 25 | lrns = .extralrns_dict$lrns 26 | for (i in seq_along(lrns)) { 27 | x$add(names(lrns)[[i]], lrns[[i]]) 28 | } 29 | } 30 | 31 | .onLoad = function(libname, pkgname) { # nolint 32 | register_namespace_callback(pkgname, "mlr3", register_mlr3) 33 | } 34 | 35 | .onUnload = function(libpath) { # nolint 36 | lrns = .extralrns_dict$lrns 37 | mlr_learners = mlr3::mlr_learners 38 | for (i in seq_along(lrns)) { 39 | mlr_learners$remove(names(lrns)[[i]]) 40 | } 41 | } 42 | 43 | # nocov end 44 | 45 | leanify_package() 46 | -------------------------------------------------------------------------------- /attic/fn_install_catboost.R: -------------------------------------------------------------------------------- 1 | #' @title Install catboost 2 | #' @description 3 | #' Helper function to install catboost. 4 | #' Installs the latest version if no version is provided. 5 | #' 6 | #' @param version `(character(1))` 7 | #' Version to install, if `NULL` installs latest. 8 | #' Can e.g. be `"1.0.6"`. 9 | #' @param INSTALL_opts `(character())` \cr 10 | #' Passed to [remotes::install_url] 11 | #' @param ... `ANY` \cr 12 | #' Other arguments passed to [remotes::install_url] 13 | #' 14 | #' @export 15 | install_catboost = function(version = NULL, 16 | INSTALL_opts = c("--no-multiarch", "--no-test-load"), ...) { 17 | 18 | if (is.null(version)) { 19 | require_namespaces(c("jsonlite", "curl", "remotes")) 20 | } 21 | 22 | version = jsonlite::fromJSON( 23 | "https://api.github.com/repos/catboost/catboost/releases" 24 | )$tag_name[1] 25 | version = gsub("v", "", version) 26 | os = as.character(Sys.info()["sysname"]) 27 | 28 | url = sprintf( 29 | "https://github.com/catboost/catboost/releases/download/v%s/catboost-R-%s-%s.tgz", 30 | version, os, version 31 | ) 32 | 33 | remotes::install_url(url, INSTALL_opts = INSTALL_opts, ...) 34 | } 35 | -------------------------------------------------------------------------------- /inst/templates/param_test_template.R: -------------------------------------------------------------------------------- 1 | test_that(". train", { 2 | learner = lrn(".") 3 | fun = :: 4 | exclude = c( 5 | "object", # handled internally 6 | "data" # handled internally 7 | ) 8 | 9 | # note that you can also pass a list of functions in case $.train calls more than one 10 | # function, e.g. for control arguments 11 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 12 | expect_paramtest(paramtest) 13 | }) 14 | 15 | test_that(". predict", { 16 | learner = lrn(".") 17 | fun = ::predict # nolint 18 | exclude = c( 19 | "object", # handled internally 20 | "data", # handled internally 21 | "newdata" # handled internally 22 | ) 23 | 24 | paramtest = run_paramtest(learner, fun, exclude, tag = "predict") 25 | expect_paramtest(paramtest) 26 | }) 27 | -------------------------------------------------------------------------------- /inst/templates/test_template.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = lrn(".") 3 | expect_learner(learner) 4 | # note that you can skip tests using the exclude argument 5 | result = run_autotest(learner) 6 | expect_true(result, info = result$error) 7 | }) 8 | -------------------------------------------------------------------------------- /man-roxygen/example.R: -------------------------------------------------------------------------------- 1 | <% 2 | pkgs = setdiff(mlr3::lrn(id)$packages, c("mlr3", "mlr3learners")) 3 | l = lrn(id) 4 | task_id = if ("LearnerClassif" %in% class(l)) { 5 | "sonar" 6 | } else if ("LearnerRegr" %in% class(l)) { 7 | "mtcars" 8 | } else if ("LearnerSurv" %in% class(l)) { 9 | "grace" 10 | } else if ("LearnerDens" %in% class(l)) { 11 | "faithful" 12 | } 13 | %> 14 | #' 15 | #' <%= sprintf("@examplesIf mlr3misc::require_namespaces(lrn(\"%s\")$packages, quietly = TRUE)", id) %> 16 | #' # Define the Learner 17 | #' <%= sprintf("learner = mlr3::lrn(\"%s\")", id)%> 18 | #' print(learner) 19 | #' 20 | #' # Define a Task 21 | #' <%= sprintf("task = mlr3::tsk(\"%s\")", task_id)%> 22 | #' 23 | #' # Create train and test set 24 | #' ids = mlr3::partition(task) 25 | #' 26 | #' # Train the learner on the training ids 27 | #' learner$train(task, row_ids = ids$train) 28 | #' 29 | #' print(learner$model) 30 | #' <%= if("importance" %in% l$properties) "print(learner$importance())" %> 31 | #' 32 | #' # Make predictions for the test rows 33 | #' predictions = learner$predict(task, row_ids = ids$test) 34 | #' 35 | #' # Score the predictions 36 | #' predictions$score() 37 | -------------------------------------------------------------------------------- /man-roxygen/install_coxboost.R: -------------------------------------------------------------------------------- 1 | #' @section Installation: 2 | #' The package 'CoxBoost' is not on CRAN and has to be installed from GitHub using 3 | #' `remotes::install_github("binderh/CoxBoost")`. 4 | -------------------------------------------------------------------------------- /man-roxygen/install_survivalmodels.R: -------------------------------------------------------------------------------- 1 | #' @section Installation: 2 | #' Package 'survivalmodels' is not on CRAN and has to be install from GitHub via 3 | #' `remotes::install_github("RaphaelS1/survivalmodels")`. 4 | -------------------------------------------------------------------------------- /man-roxygen/learner.R: -------------------------------------------------------------------------------- 1 | #' @section Dictionary: 2 | #' This [Learner][mlr3::Learner] can be instantiated via [lrn()][mlr3::lrn]: 3 | #' ``` 4 | #' lrn("<%= id %>") 5 | #' ``` 6 | #' 7 | #' @section Meta Information: 8 | #' `r paste(mlr3misc::rd_info(mlr3::lrn("<%= id %>")), collapse = "\n")` 9 | #' @md 10 | #' 11 | #' @section Parameters: 12 | #' `r paste(mlr3misc::rd_info(mlr3::lrn("<%= id %>")$param_set), collapse = "\n")` 13 | #' @md 14 | -------------------------------------------------------------------------------- /man-roxygen/note_xgboost.R: -------------------------------------------------------------------------------- 1 | #' @note 2 | #' To compute on GPUs, you first need to compile \CRANpkg{xgboost} yourself and link 3 | #' against CUDA. 4 | #' See \url{https://xgboost.readthedocs.io/en/stable/build.html#building-with-gpu-support}. 5 | -------------------------------------------------------------------------------- /man-roxygen/section_early_stopping.R: -------------------------------------------------------------------------------- 1 | #' @section Early stopping: 2 | #' Early stopping can be used to find the optimal number of boosting rounds. 3 | #' The `early_stopping_set` parameter controls which set is used to monitor the 4 | #' performance. 5 | #' By default, `early_stopping_set = "none"` which disables early stopping. 6 | #' Set `early_stopping_set = "test"` to monitor the performance of the model on 7 | #' the test set while training. 8 | #' The test set for early stopping can be set with the `"test"` row role in the 9 | #' [mlr3::Task]. 10 | #' Additionally, the range must be set in which the performance must increase 11 | #' with `early_stopping_rounds` and the maximum number of boosting rounds with 12 | #' `nrounds`. 13 | #' While resampling, the test set is automatically applied from the [mlr3::Resampling]. 14 | #' Not that using the test set for early stopping can potentially bias the 15 | #' performance scores. 16 | -------------------------------------------------------------------------------- /man-roxygen/section_formula.R: -------------------------------------------------------------------------------- 1 | #' @section Formula: 2 | #' Although most mlr3 learners don't allow to specify the formula manually, and automatically 3 | #' set it by valling `task$formula()`, this learner allows to set the `formula` because it's core 4 | #' functionality depends it. This means that it might not always use all features that are available 5 | #' in the [task][mlr3::Task]. 6 | #' Be aware, that this can sometimes lead to unexpected error messages, 7 | #' because mlr3 checks the compatibility between the learner and the task on **all** available features. 8 | -------------------------------------------------------------------------------- /man-roxygen/sections_tabpfn.R: -------------------------------------------------------------------------------- 1 | #' @section Installation: 2 | #' While the Python dependencies are handled via `reticulate::py_require()`, you can 3 | #' manually specify a virtual environment by calling `reticulate::use_virtualenv()` 4 | #' prior to calling the `$train()` function. 5 | #' In this virtual environment, the `tabpfn` package and its dependencies must be installed. 6 | #' 7 | #' @section Saving a Learner: 8 | #' In order to save a `<%= class %>` for later usage, 9 | #' it is necessary to call the `$marshal()` method on the `Learner` 10 | #' before writing it to disk, as the object will otherwise not be saved correctly. 11 | #' After loading a marshaled `<%= class %>` into R again, 12 | #' you then need to call `$unmarshal()` to transform it into a useable state. 13 | #' 14 | #' @section Initial parameter values: 15 | #' - `n_jobs` is initialized to 1 to avoid threading conflicts with \CRANpkg{future}. 16 | -------------------------------------------------------------------------------- /man-roxygen/seealso_learner.R: -------------------------------------------------------------------------------- 1 | #' @seealso 2 | #' * [Dictionary][mlr3misc::Dictionary] of [Learners][mlr3::Learner]: [mlr3::mlr_learners]. 3 | #' * `as.data.table(mlr_learners)` for a table of available [Learners][mlr3::Learner] in the running session (depending on the loaded packages). 4 | #' * Chapter in the [mlr3book](https://mlr3book.mlr-org.com/): \url{https://mlr3book.mlr-org.com/basics.html#learners} 5 | #' * \CRANpkg{mlr3learners} for a selection of recommended learners. 6 | #' * \CRANpkg{mlr3cluster} for unsupervised clustering learners. 7 | #' * \CRANpkg{mlr3pipelines} to combine learners with pre- and postprocessing steps. 8 | #' * \CRANpkg{mlr3tuning} for tuning of hyperparameters, \CRANpkg{mlr3tuningspaces} for established default tuning spaces. 9 | -------------------------------------------------------------------------------- /man-roxygen/simple_example.R: -------------------------------------------------------------------------------- 1 | #' @examples 2 | #' <%= sprintf("lrn(\"%s\")", id)%> 3 | -------------------------------------------------------------------------------- /man/figures/logo_navbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mlr-org/mlr3extralearners/80f4c3dd54e96f5dfef2e75662e5ce3b0e3d2b0b/man/figures/logo_navbar.png -------------------------------------------------------------------------------- /man/install_learners.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/fn_install_learners.R 3 | \name{install_learners} 4 | \alias{install_learners} 5 | \title{Install Learner Dependencies} 6 | \usage{ 7 | install_learners(.keys, repos = "https://cloud.r-project.org", ...) 8 | } 9 | \arguments{ 10 | \item{.keys}{(\code{character()}) \cr Keys passed to \link[mlr3:mlr_learners]{mlr_learners} specifying 11 | learners to install.} 12 | 13 | \item{repos}{(\code{character(1)}) \cr Passed to \link[utils:install.packages]{utils::install.packages}.} 14 | 15 | \item{...}{(\code{ANY}) \cr Additional options to pass to \link[utils:install.packages]{utils::install.packages} or 16 | \link[remotes:install_github]{remotes::install_github}.} 17 | } 18 | \description{ 19 | Install required dependencies for specified learners. Works for packages on 20 | GitHub and CRAN, otherwise must be manually installed. 21 | } 22 | -------------------------------------------------------------------------------- /man/list_mlr3learners.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/fn_list_mlr3learners.R 3 | \name{list_mlr3learners} 4 | \alias{list_mlr3learners} 5 | \title{List Learners in mlr3verse} 6 | \usage{ 7 | list_mlr3learners(select = NULL, filter = NULL) 8 | } 9 | \arguments{ 10 | \item{select}{\code{character()} \cr Passed to \link[data.table:subset.data.table]{data.table::subset}.} 11 | 12 | \item{filter}{\code{list()} \cr Named list of conditions to filter on, names correspond to column 13 | names in table.} 14 | } 15 | \description{ 16 | Lists all learners, properties, and associated packages in a table that can be 17 | filtered and queried. 18 | } 19 | -------------------------------------------------------------------------------- /man/reexports.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/zzz.R 3 | \docType{import} 4 | \name{reexports} 5 | \alias{reexports} 6 | \alias{lrn} 7 | \alias{lrns} 8 | \title{Objects exported from other packages} 9 | \keyword{internal} 10 | \description{ 11 | These objects are imported from other packages. Follow the links 12 | below to see their documentation. 13 | 14 | \describe{ 15 | \item{mlr3}{\code{\link[mlr3:mlr_sugar]{lrn}}, \code{\link[mlr3:mlr_sugar]{lrns}}} 16 | }} 17 | 18 | -------------------------------------------------------------------------------- /mlr3extralearners.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | StripTrailingWhitespace: Yes 16 | 17 | BuildType: Package 18 | PackageUseDevtools: Yes 19 | PackageInstallArgs: --no-multiarch --with-keep.source 20 | PackageRoxygenize: rd,collate,namespace 21 | -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-120x120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mlr-org/mlr3extralearners/80f4c3dd54e96f5dfef2e75662e5ce3b0e3d2b0b/pkgdown/favicon/apple-touch-icon-120x120.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-152x152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mlr-org/mlr3extralearners/80f4c3dd54e96f5dfef2e75662e5ce3b0e3d2b0b/pkgdown/favicon/apple-touch-icon-152x152.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-180x180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mlr-org/mlr3extralearners/80f4c3dd54e96f5dfef2e75662e5ce3b0e3d2b0b/pkgdown/favicon/apple-touch-icon-180x180.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-60x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mlr-org/mlr3extralearners/80f4c3dd54e96f5dfef2e75662e5ce3b0e3d2b0b/pkgdown/favicon/apple-touch-icon-60x60.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-76x76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mlr-org/mlr3extralearners/80f4c3dd54e96f5dfef2e75662e5ce3b0e3d2b0b/pkgdown/favicon/apple-touch-icon-76x76.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mlr-org/mlr3extralearners/80f4c3dd54e96f5dfef2e75662e5ce3b0e3d2b0b/pkgdown/favicon/apple-touch-icon.png -------------------------------------------------------------------------------- /pkgdown/favicon/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mlr-org/mlr3extralearners/80f4c3dd54e96f5dfef2e75662e5ce3b0e3d2b0b/pkgdown/favicon/favicon-16x16.png -------------------------------------------------------------------------------- /pkgdown/favicon/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mlr-org/mlr3extralearners/80f4c3dd54e96f5dfef2e75662e5ce3b0e3d2b0b/pkgdown/favicon/favicon-32x32.png -------------------------------------------------------------------------------- /pkgdown/favicon/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mlr-org/mlr3extralearners/80f4c3dd54e96f5dfef2e75662e5ce3b0e3d2b0b/pkgdown/favicon/favicon.ico -------------------------------------------------------------------------------- /tests/testthat.R: -------------------------------------------------------------------------------- 1 | if (requireNamespace("testthat", quietly = TRUE)) { 2 | library("testthat") 3 | library("mlr3extralearners") 4 | test_check("mlr3extralearners") 5 | } 6 | -------------------------------------------------------------------------------- /tests/testthat/test_BART_surv_bart.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = lrn("surv.bart", nskip = 1, ndpost = 1, keepevery = 1) 3 | expect_learner(learner) 4 | result = run_autotest(learner) 5 | expect_true(result, info = result$error) 6 | }) 7 | -------------------------------------------------------------------------------- /tests/testthat/test_C50_classif_C50.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = LearnerClassifC50$new() 3 | learner$param_set$values = list(trials = 1L) 4 | expect_learner(learner) 5 | result = run_autotest(learner) 6 | expect_true(result, info = result$error) 7 | }) 8 | -------------------------------------------------------------------------------- /tests/testthat/test_CoxBoost_surv_coxboost.R: -------------------------------------------------------------------------------- 1 | test_that("autotest surv.coxboost", { 2 | learner = LearnerSurvCoxboost$new() 3 | expect_learner(learner) 4 | result = run_autotest(learner, check_replicable = FALSE) 5 | expect_true(result, info = result$error) 6 | }) 7 | -------------------------------------------------------------------------------- /tests/testthat/test_CoxBoost_surv_cv_coxboost.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | set.seed(1) 3 | learner = lrn("surv.cv_coxboost", maxstepno = 1, K = 2) 4 | expect_learner(learner) 5 | result = run_autotest(learner, N = 10, check_replicable = FALSE) 6 | expect_true(result, info = result$error) 7 | }) 8 | 9 | test_that("optim", { 10 | set.seed(1) 11 | learner = lrn("surv.cv_coxboost", 12 | penalty = "optimCoxBoostPenalty", 13 | maxstepno = 1, minstepno = 0, iter.max = 1, K = 2) 14 | task = tsk("rats") 15 | task$select(c("litter", "rx")) 16 | expect_prediction_surv( 17 | suppressWarnings(learner$train(task, row_ids = 1:50)$predict(task, row_ids = 51:100)) 18 | ) 19 | expect_equal(learner$selected_features(at_step = 0), character()) 20 | expect_equal(learner$selected_features(), "litter") 21 | expect_error(learner$selected_features(at_step = 2)) # maxstepno = 1 22 | }) 23 | -------------------------------------------------------------------------------- /tests/testthat/test_Cubist_regr_cubist.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = lrn("regr.cubist") 3 | expect_learner(learner) 4 | result = run_autotest(learner) 5 | expect_true(result, info = result$error) 6 | }) 7 | -------------------------------------------------------------------------------- /tests/testthat/test_FNN_classif_fnn.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = LearnerClassifFNN$new() 3 | learner$param_set$values = list(k = 10) 4 | expect_learner(learner) 5 | result = run_autotest(learner, predict_types = "response") 6 | expect_true(result, info = result$error) 7 | }) 8 | -------------------------------------------------------------------------------- /tests/testthat/test_FNN_regr_fnn.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = LearnerRegrFNN$new() 3 | learner$param_set$values = list(k = 10) 4 | expect_learner(learner) 5 | result = run_autotest(learner) 6 | expect_true(result, info = result$error) 7 | }) 8 | -------------------------------------------------------------------------------- /tests/testthat/test_LiblineaR_classif_liblinear.R: -------------------------------------------------------------------------------- 1 | install_learners("classif.liblinear") 2 | 3 | test_that("autotest", { 4 | learner = LearnerClassifLiblineaR$new() 5 | expect_learner(learner) 6 | result = run_autotest(learner) 7 | expect_true(result, info = result$error) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test_LiblineaR_regr_liblinear.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = LearnerRegrLiblineaR$new() 3 | expect_learner(learner) 4 | result = run_autotest(learner) 5 | expect_true(result, info = result$error) 6 | }) 7 | -------------------------------------------------------------------------------- /tests/testthat/test_RWeka_classif_AdaBoostM1.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("autotest", { 4 | learner = LearnerClassifAdaBoostM1$new() 5 | expect_learner(learner) 6 | result = run_autotest(learner) 7 | expect_true(result, info = result$error) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test_RWeka_classif_IBk.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("autotest", { 4 | learner = LearnerClassifIBk$new() 5 | expect_learner(learner) 6 | result = run_autotest(learner) 7 | expect_true(result, info = result$error) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test_RWeka_classif_J48.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("autotest", { 4 | learner = LearnerClassifJ48$new() 5 | expect_learner(learner) 6 | result = run_autotest(learner, exclude = "missings_each_row_binary|missings_each_row_multiclass") 7 | expect_true(result, info = result$error) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test_RWeka_classif_JRip.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("autotest", { 4 | learner = LearnerClassifJRip$new() 5 | expect_learner(learner) 6 | result = run_autotest(learner) 7 | expect_true(result, info = result$error) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test_RWeka_classif_LMT.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("autotest", { 4 | learner = LearnerClassifLMT$new() 5 | expect_learner(learner) 6 | result = run_autotest(learner) 7 | expect_true(result, info = result$error) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test_RWeka_classif_OneR.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("autotest", { 4 | learner = LearnerClassifOneR$new() 5 | expect_learner(learner) 6 | result = run_autotest(learner) 7 | expect_true(result, info = result$error) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test_RWeka_classif_PART.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("autotest", { 4 | learner = LearnerClassifPART$new() 5 | expect_learner(learner) 6 | result = run_autotest(learner, exclude = "missings_each_row") 7 | expect_true(result, info = result$error) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test_RWeka_classif_bayes_net.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("autotest", { 4 | learner = lrn("classif.bayes_net") 5 | expect_learner(learner) 6 | result = run_autotest(learner, exclude = "(missings_each_row)") 7 | expect_true(result, info = result$error) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test_RWeka_classif_decision_stump.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("autotest", { 4 | learner = lrn("classif.decision_stump") 5 | expect_learner(learner) 6 | result = run_autotest(learner, exclude = "missings_each_row_binary|missings_each_row_multiclass") 7 | expect_true(result, info = result$error) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test_RWeka_classif_decision_table.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("autotest", { 4 | learner = lrn("classif.decision_table") 5 | expect_learner(learner) 6 | result = run_autotest(learner, exclude = "(missings_each_row)") 7 | expect_true(result, info = result$error) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test_RWeka_classif_kstar.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("autotest", { 4 | learner = lrn("classif.kstar") 5 | expect_learner(learner) 6 | result = run_autotest(learner) 7 | expect_true(result, info = result$error) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test_RWeka_classif_logistic.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("autotest", { 4 | learner = lrn("classif.logistic") 5 | expect_learner(learner) 6 | result = run_autotest(learner, exclude = "missings_each_row_binary|missings_each_row_multiclass") 7 | expect_true(result, info = result$error) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test_RWeka_classif_multilayer_perceptron.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("autotest", { 4 | learner = lrn("classif.multilayer_perceptron") 5 | expect_learner(learner) 6 | result = run_autotest(learner, exclude = "missings_each_row_binary|missings_each_row_multiclass") 7 | expect_true(result, info = result$error) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test_RWeka_classif_naive_bayes_multinomial.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("autotest", { 4 | learner = lrn("classif.naive_bayes_multinomial") 5 | expect_learner(learner) 6 | result = run_autotest(learner, exclude = "sanity") 7 | expect_true(result, info = result$error) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test_RWeka_classif_naive_bayes_weka.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("autotest", { 4 | learner = lrn("classif.naive_bayes_weka") 5 | expect_learner(learner) 6 | result = run_autotest(learner) 7 | expect_true(result, info = result$error) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test_RWeka_classif_random_forest_weka.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("autotest", { 4 | learner = lrn("classif.random_forest_weka") 5 | expect_learner(learner) 6 | result = run_autotest(learner, exclude = "missings_each_row_binary|missings_each_row_multiclass") 7 | expect_true(result, info = result$error) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test_RWeka_classif_random_tree.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("autotest", { 4 | learner = lrn("classif.random_tree") 5 | expect_learner(learner) 6 | result = run_autotest(learner, exclude = "missings_each_row_binary|missings_each_row_multiclass") 7 | expect_true(result, info = result$error) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test_RWeka_classif_reptree.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("autotest", { 4 | learner = lrn("classif.reptree") 5 | expect_learner(learner) 6 | result = run_autotest(learner, exclude = "(missings_each_row)") 7 | expect_true(result, info = result$error) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test_RWeka_classif_sgd.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("autotest", { 4 | learner = lrn("classif.sgd") 5 | expect_learner(learner) 6 | result = run_autotest(learner) 7 | expect_true(result, info = result$error) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test_RWeka_classif_simple_logistic.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("autotest", { 4 | learner = lrn("classif.simple_logistic") 5 | expect_learner(learner) 6 | result = run_autotest(learner, exclude = "missings_each_row_binary|missings_each_row_multiclass") 7 | expect_true(result, info = result$error) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test_RWeka_classif_smo.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("autotest", { 4 | learner = lrn("classif.smo") 5 | expect_learner(learner) 6 | result = run_autotest(learner, exclude = "missings_each_row_binary|missings_each_row_multiclass") 7 | expect_true(result, info = result$error) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test_RWeka_classif_voted_perceptron.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("autotest", { 4 | learner = lrn("classif.voted_perceptron") 5 | expect_learner(learner) 6 | result = run_autotest(learner) 7 | expect_true(result, info = result$error) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test_RWeka_regr_IBk.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("autotest", { 4 | learner = LearnerRegrIBk$new() 5 | expect_learner(learner) 6 | result = run_autotest(learner) 7 | expect_true(result, info = result$error) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test_RWeka_regr_M5Rules.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("autotest", { 4 | learner = LearnerRegrM5Rules$new() 5 | expect_learner(learner) 6 | # these parameters have to be set as otherwise the sanity check does not run 7 | learner$param_set$values = list(M = 1L, N = TRUE, U = TRUE) 8 | result = run_autotest(learner) 9 | expect_true(result, info = result$error) 10 | }) 11 | -------------------------------------------------------------------------------- /tests/testthat/test_RWeka_regr_decision_stump.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("autotest", { 4 | learner = lrn("regr.decision_stump") 5 | expect_learner(learner) 6 | result = run_autotest(learner, exclude = "sanity|missings_each_row") 7 | expect_true(result, info = result$error) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test_RWeka_regr_decision_table.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("autotest", { 4 | learner = lrn("regr.decision_table") 5 | expect_learner(learner) 6 | result = run_autotest(learner) 7 | expect_true(result, info = result$error) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test_RWeka_regr_gaussian_processes.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("autotest", { 4 | learner = lrn("regr.gaussian_processes") 5 | expect_learner(learner) 6 | result = run_autotest(learner, exclude = "sanity|missings_each_row") 7 | expect_true(result, info = result$error) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test_RWeka_regr_kstar.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("autotest", { 4 | learner = lrn("regr.kstar") 5 | expect_learner(learner) 6 | result = run_autotest(learner) 7 | expect_true(result, info = result$error) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test_RWeka_regr_linear_regression.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("autotest", { 4 | learner = lrn("regr.linear_regression") 5 | expect_learner(learner) 6 | result = run_autotest(learner, exclude = "missings_each_row") 7 | expect_true(result, info = result$error) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test_RWeka_regr_m5p.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("autotest", { 4 | learner = lrn("regr.m5p") 5 | expect_learner(learner) 6 | result = run_autotest(learner, exclude = "(sanity)") 7 | expect_true(result, info = result$error) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test_RWeka_regr_multilayer_perceptron.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("autotest", { 4 | learner = lrn("regr.multilayer_perceptron") 5 | expect_learner(learner) 6 | result = run_autotest(learner, exclude = "missings_each_row_binary|missings_each_row") 7 | expect_true(result, info = result$error) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test_RWeka_regr_random_forest_weka.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("autotest", { 4 | learner = lrn("regr.random_forest_weka") 5 | expect_learner(learner) 6 | result = run_autotest(learner) 7 | expect_true(result, info = result$error) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test_RWeka_regr_random_tree.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("autotest", { 4 | learner = lrn("regr.random_tree") 5 | expect_learner(learner) 6 | result = run_autotest(learner, exclude = "missings_each_row") 7 | expect_true(result, info = result$error) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test_RWeka_regr_reptree.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("autotest", { 4 | learner = lrn("regr.reptree") 5 | expect_learner(learner) 6 | result = run_autotest(learner) 7 | expect_true(result, info = result$error) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test_RWeka_regr_sgd.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("autotest", { 4 | learner = lrn("regr.sgd") 5 | expect_learner(learner) 6 | result = run_autotest(learner) 7 | expect_true(result, info = result$error) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test_RWeka_regr_simple_linear_regression.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("autotest", { 4 | learner = lrn("regr.simple_linear_regression") 5 | expect_learner(learner) 6 | result = run_autotest(learner, exclude = "missings_each_row") 7 | expect_true(result, info = result$error) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test_RWeka_regr_smo_reg.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("autotest", { 4 | learner = lrn("regr.smo_reg") 5 | expect_learner(learner) 6 | result = run_autotest(learner, exclude = "missings_each_row") 7 | expect_true(result, info = result$error) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test_abess_classif_abess.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = lrn("classif.abess") 3 | expect_learner(learner) 4 | result = run_autotest(learner, check_replicable = FALSE) 5 | 6 | expect_true(result, info = result$error) 7 | }) 8 | -------------------------------------------------------------------------------- /tests/testthat/test_abess_regr_abess.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = lrn("regr.abess") 3 | expect_learner(learner) 4 | result = run_autotest(learner) 5 | expect_true(result, info = result$error) 6 | }) 7 | -------------------------------------------------------------------------------- /tests/testthat/test_aorsf_classif_aorsf.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = lrn("classif.aorsf") 3 | expect_learner(learner) 4 | result = run_autotest( 5 | learner, 6 | exclude = "utf8_feature_names", 7 | N = 30 8 | ) 9 | expect_true(result, info = result$error) 10 | }) 11 | -------------------------------------------------------------------------------- /tests/testthat/test_aorsf_regr_aorsf.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = lrn("regr.aorsf") 3 | expect_learner(learner) 4 | result = run_autotest( 5 | learner, 6 | exclude = "utf8_feature_names || feat_logical", 7 | N = 30 8 | ) 9 | expect_true(result, info = result$error) 10 | }) 11 | -------------------------------------------------------------------------------- /tests/testthat/test_aorsf_surv_aorsf.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | set.seed(1) # there was presumable a weird bug 3 | learner = lrn("surv.aorsf") 4 | expect_learner(learner) 5 | # for some reason the feat_all test randomly stopped working, check later if the 6 | # problem goes away (could not reproduce locally) 7 | result = run_autotest(learner, 8 | exclude = "single || feat_all", 9 | N = 30, 10 | check_replicable = FALSE) 11 | expect_true(result, info = result$error) 12 | }) 13 | 14 | test_that("predicted time matches aorsf", { 15 | # time prediction is handled outside of aorsf. 16 | # this test is placed to ensure that we don't diverge. 17 | skip_if_not(utils::packageVersion("aorsf") > "0.1.3") 18 | task = tsk("lung") 19 | aorsf = lrn("surv.aorsf", control_type = "fast") 20 | aorsf$train(task) 21 | preds_mlr3 = aorsf$predict(task) 22 | preds_aorsf = predict(aorsf$model, 23 | new_data = task$data(), 24 | pred_type = "time") 25 | expect_equal(preds_mlr3$response, as.numeric(preds_aorsf)) 26 | }) 27 | -------------------------------------------------------------------------------- /tests/testthat/test_catboost_classif_catboost.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = lrn("classif.catboost", iterations = 10) 3 | expect_learner(learner) 4 | result = run_autotest(learner) 5 | expect_true(result, info = result$error) 6 | }) 7 | 8 | test_that("#353", { 9 | iris_task = tsk("iris") 10 | lrn_catboost_classif = lrn("classif.catboost", predict_type = "prob") 11 | resamp = rsmp("holdout") 12 | rr = resample(iris_task, 13 | learner = lrn_catboost_classif, 14 | resampling = resamp 15 | ) 16 | 17 | pred = rr$prediction() 18 | assert_true(all(abs(rowSums(pred$prob) - 1) < 0.001)) 19 | }) 20 | 21 | test_that("early stopping works", { 22 | learner = lrn("classif.catboost", iterations = 1000, eval_metric = "Logloss", early_stopping_rounds = 10) 23 | learner$validate = 0.2 24 | task = tsk("pima") 25 | 26 | learner$train(task) 27 | 28 | expect_list(learner$internal_tuned_values) 29 | expect_number(learner$internal_tuned_values$iterations) 30 | }) 31 | -------------------------------------------------------------------------------- /tests/testthat/test_catboost_regr_catboost.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = lrn("regr.catboost", iterations = 10) 3 | expect_learner(learner) 4 | result = run_autotest(learner) 5 | expect_true(result, info = result$error) 6 | }) 7 | 8 | test_that("early stopping works", { 9 | learner = lrn("regr.catboost", iterations = 1000, early_stopping_rounds = 10) 10 | learner$validate = 0.2 11 | task = tsk("mtcars") 12 | 13 | learner$train(task) 14 | 15 | expect_list(learner$internal_tuned_values) 16 | expect_number(learner$internal_tuned_values$iterations) 17 | }) 18 | -------------------------------------------------------------------------------- /tests/testthat/test_dbarts_classif_bart.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = lrn("classif.bart") 3 | 4 | learner$param_set$values = c( 5 | learner$param_set$values, 6 | ntree = 5L 7 | ) 8 | 9 | expect_learner(learner) 10 | result = run_autotest(learner, exclude = "sanity|utf8_feature_names") 11 | expect_true(result, info = result$error) 12 | }) 13 | -------------------------------------------------------------------------------- /tests/testthat/test_dbarts_regr_bart.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = lrn("regr.bart") 3 | 4 | learner$param_set$values = c( 5 | learner$param_set$values, 6 | ntree = 5L) 7 | 8 | expect_learner(learner) 9 | result = run_autotest(learner, exclude = "utf8_feature_names") 10 | expect_true(result, info = result$error) 11 | }) 12 | -------------------------------------------------------------------------------- /tests/testthat/test_earth_classif_earth.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = lrn("classif.earth", varmod.method = "const", nfold = 2, ncross = 3) 3 | expect_learner(learner) 4 | result = run_autotest(learner) 5 | expect_true(result, info = result$error) 6 | }) 7 | -------------------------------------------------------------------------------- /tests/testthat/test_earth_regr_earth.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = lrn("regr.earth", varmod.method = "const", nfold = 2, ncross = 3) 3 | expect_learner(learner) 4 | result = run_autotest(learner) 5 | expect_true(result, info = result$error) 6 | }) 7 | -------------------------------------------------------------------------------- /tests/testthat/test_encode_data_lightgbm.R: -------------------------------------------------------------------------------- 1 | test_that("encode_data_lightgbm works for train", { 2 | dat = data.table::data.table( 3 | y = rnorm(100), 4 | x_fct = factor(sample(letters, 100, TRUE)), 5 | x_lgl = sample(c(TRUE, FALSE), 100, TRUE) 6 | ) 7 | task = as_task_regr(dat, target = "y") 8 | learner = lrn("regr.lightgbm") 9 | expect_error(learner$train(task), regexp = NA) 10 | learner$predict(task) 11 | 12 | newdata = data.table::data.table(y = 1, x_fct = factor("zzz"), x_lgl = TRUE) 13 | 14 | expect_error(learner$predict_newdata(newdata), "received task with different column info") 15 | 16 | expect_error(learner$predict(task), regexp = NA) 17 | expect_error(learner$train(task), regexp = NA) 18 | expect_error(learner$predict(task), regexp = NA) 19 | }) 20 | -------------------------------------------------------------------------------- /tests/testthat/test_flexsurv_surv_flexible.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | with_seed(200, { 3 | learner = lrn("surv.flexible", k = 1, scale = "normal", inits = c(0.1, 1)) 4 | expect_learner(learner) 5 | # sanity excluded due to issues in optimisation (it's too easy...) 6 | result = run_autotest(learner, check_replicable = FALSE, exclude = "sanity") 7 | expect_true(result, info = result$error) 8 | }) 9 | }) 10 | 11 | test_that("manualtest", { 12 | with_seed(1, { 13 | task = tsk("rats") 14 | learn = lrn("surv.flexible", k = 1, scale = "normal", inits = c(1, 1, 1)) 15 | learn$train(task) 16 | p = learn$predict(task) 17 | # Comparison to flexsurv 18 | expect_equal( 19 | p$lp[1:20], 20 | summary(learn$model, 21 | task$data(cols = task$feature_names), 22 | se = FALSE, ci = FALSE, type = "link", tidy = TRUE)[1:20, 2] 23 | ) 24 | expect_equal( 25 | p$distr[2]$survival(1:23), 26 | summary(learn$model, 27 | task$data(cols = task$feature_names), 28 | se = FALSE, ci = FALSE, type = "survival", tidy = TRUE, t = 1:23)[24:46, 2], 29 | tolerance = 0.0001 30 | ) 31 | }) 32 | }) 33 | 34 | test_that("missing", { 35 | learner = lrn("surv.flexible", k = 1) 36 | learner$train(tsk("lung")) 37 | expect_error(learner$predict(lung_missings)) 38 | }) 39 | -------------------------------------------------------------------------------- /tests/testthat/test_gbm_classif_gbm.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = LearnerClassifGBM$new() 3 | learner$param_set$values = mlr3misc::insert_named( 4 | learner$param_set$values, 5 | list(n.minobsinnode = 1)) 6 | expect_learner(learner) 7 | result = run_autotest(learner, exclude = "feat_single_multiclass || weights_binary") 8 | expect_true(result, info = result$error) 9 | }) 10 | -------------------------------------------------------------------------------- /tests/testthat/test_gbm_regr_gbm.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = mlr3::lrn("regr.gbm") 3 | learner$param_set$values = mlr3misc::insert_named( 4 | learner$param_set$values, 5 | list(n.minobsinnode = 1)) 6 | expect_learner(learner) 7 | result = run_autotest(learner, predict_types = "response") 8 | expect_true(result, info = result$error) 9 | }) 10 | 11 | test_that("quantile prediction", { 12 | learner = mlr3::lrn("regr.gbm", 13 | predict_type = "quantiles", 14 | quantiles = 0.1, 15 | n.minobsinnode = 1) 16 | task = tsk("mtcars") 17 | 18 | learner$train(task) 19 | pred = learner$predict(task) 20 | 21 | expect_matrix(pred$quantiles, ncol = 1L) 22 | expect_true(!any(apply(pred$quantiles, 1L, is.unsorted))) 23 | expect_equal(pred$response, pred$quantiles[, 1L]) 24 | 25 | tab = as.data.table(pred) 26 | expect_names(names(tab), identical.to = c("row_ids", "truth", "q0.1", "response")) 27 | expect_equal(tab$response, tab$q0.1) 28 | }) 29 | -------------------------------------------------------------------------------- /tests/testthat/test_gbm_surv_gbm.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | set.seed(1) 3 | # set low value for min obs b/c of small n in autogenerated tasks 4 | learner = lrn("surv.gbm", id = "gbm", n.minobsinnode = 1L, n.trees = 100L) 5 | expect_learner(learner) 6 | result = run_autotest(learner, check_replicable = FALSE) 7 | expect_true(result, info = result$error) 8 | expect_error(learner$importance(), "No model stored") 9 | learner$train(tsk("rats"))$importance() 10 | }) 11 | -------------------------------------------------------------------------------- /tests/testthat/test_gss_dens_spline.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = lrn("dens.spline") 3 | expect_learner(learner) 4 | result = run_autotest(learner) 5 | expect_true(result, info = result$error) 6 | }) 7 | -------------------------------------------------------------------------------- /tests/testthat/test_kernlab_classif_gausspr.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = lrn("classif.gausspr") 3 | expect_learner(learner) 4 | result = run_autotest(learner) 5 | expect_true(result, info = result$error) 6 | }) 7 | 8 | test_that("classif.gausspr sigma", { 9 | learner = lrn("classif.gausspr", tol = 0.1, kpar = list(sigma = 0.2)) 10 | t = tsk("iris") 11 | 12 | learner$train(t) 13 | expect_equal(learner$model@kernelf@kpar$sigma, 0.2) 14 | 15 | learner = lrn("classif.gausspr", tol = 0.1, sigma = 0.2) 16 | learner$train(t) 17 | expect_equal(learner$model@kernelf@kpar$sigma, 0.2) 18 | }) 19 | -------------------------------------------------------------------------------- /tests/testthat/test_kernlab_classif_ksvm.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = LearnerClassifKSVM$new() 3 | expect_learner(learner) 4 | result = run_autotest(learner) 5 | expect_true(result, info = result$error) 6 | }) 7 | -------------------------------------------------------------------------------- /tests/testthat/test_kernlab_classif_lssvm.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | set.seed(1) 3 | learner = lrn("classif.lssvm") 4 | expect_learner(learner) 5 | result = run_autotest(learner, exclude = "single|utf8_feature_names_multiclass", N = 50) 6 | expect_true(result, info = result$error) 7 | }) 8 | 9 | test_that("classif.lssvm sigma", { 10 | learner = lrn("classif.lssvm", kpar = list(sigma = 0.2)) 11 | t = tsk("iris") 12 | learner$train(t) 13 | expect_equal(learner$model@kernelf@kpar$sigma, 0.2) 14 | 15 | learner = lrn("classif.lssvm", sigma = 0.2) 16 | learner$train(t) 17 | expect_equal(learner$model@kernelf@kpar$sigma, 0.2) 18 | }) 19 | -------------------------------------------------------------------------------- /tests/testthat/test_kernlab_regr_gausspr.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = lrn("regr.gausspr") 3 | expect_learner(learner) 4 | result = run_autotest(learner) 5 | expect_true(result, info = result$error) 6 | }) 7 | 8 | test_that("regr.gausspr sigma", { 9 | learner = lrn("regr.gausspr", tol = 0.1, kpar = list(sigma = 0.2)) 10 | t = tsk("mtcars") 11 | learner$train(t) 12 | expect_equal(learner$model@kernelf@kpar$sigma, 0.2) 13 | 14 | learner = lrn("regr.gausspr", tol = 0.1, sigma = 0.2) 15 | learner$train(t) 16 | expect_equal(learner$model@kernelf@kpar$sigma, 0.2) 17 | }) 18 | -------------------------------------------------------------------------------- /tests/testthat/test_kernlab_regr_ksvm.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = LearnerRegrKSVM$new() 3 | expect_learner(learner) 4 | result = run_autotest(learner) 5 | expect_true(result, info = result$error) 6 | }) 7 | -------------------------------------------------------------------------------- /tests/testthat/test_kernlab_regr_rvm.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | set.seed(2) 3 | learner = lrn("regr.rvm") 4 | expect_learner(learner) 5 | result = run_autotest(learner) 6 | expect_true(result, info = result$error) 7 | }) 8 | 9 | test_that("regr.rvm sigma", { 10 | learner = lrn("regr.rvm", kpar = list(sigma = 0.2)) 11 | t = tsk("mtcars") 12 | learner$train(t) 13 | expect_equal(learner$model@kernelf@kpar$sigma, 0.2) 14 | 15 | learner = lrn("regr.rvm", sigma = 0.2) 16 | learner$train(t) 17 | expect_equal(learner$model@kernelf@kpar$sigma, 0.2) 18 | }) 19 | -------------------------------------------------------------------------------- /tests/testthat/test_ks_dens_kde_ks.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = LearnerDensKDEks$new() 3 | expect_learner(learner) 4 | result = run_autotest(learner) 5 | expect_true(result, info = result$error) 6 | }) 7 | -------------------------------------------------------------------------------- /tests/testthat/test_locfit_dens_locfit.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = LearnerDensLocfit$new() 3 | expect_learner(learner) 4 | result = run_autotest(learner) 5 | expect_true(result, info = result$error) 6 | }) 7 | -------------------------------------------------------------------------------- /tests/testthat/test_logspline_dens_logspline.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = LearnerDensLogspline$new() 3 | expect_learner(learner) 4 | result = run_autotest(learner) 5 | expect_true(result, info = result$error) 6 | }) 7 | -------------------------------------------------------------------------------- /tests/testthat/test_mboost_classif_gamboost.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = LearnerClassifGAMBoost$new() 3 | learner$param_set$values = list(baselearner = "btree", family = "Binomial") 4 | expect_learner(learner) 5 | result = run_autotest(learner, exclude = "utf8_feature_names") 6 | expect_true(result, info = result$error) 7 | }) 8 | -------------------------------------------------------------------------------- /tests/testthat/test_mboost_classif_glmboost.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = LearnerClassifGLMBoost$new() 3 | expect_learner(learner) 4 | result = run_autotest(learner, exclude = "utf8_feature_names") 5 | expect_true(result, info = result$error) 6 | }) 7 | -------------------------------------------------------------------------------- /tests/testthat/test_mboost_regr_gamboost.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = LearnerRegrGAMBoost$new() 3 | learner$param_set$values = list(baselearner = "btree") 4 | expect_learner(learner) 5 | result = run_autotest(learner, exclude = "utf8_feature_names") 6 | expect_true(result, info = result$error) 7 | }) 8 | -------------------------------------------------------------------------------- /tests/testthat/test_mboost_regr_glmboost.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = LearnerRegrGLMBoost$new() 3 | expect_learner(learner) 4 | result = run_autotest(learner, exclude = "utf8_feature_names") 5 | expect_true(result, info = result$error) 6 | }) 7 | -------------------------------------------------------------------------------- /tests/testthat/test_mboost_surv_blackboost.R: -------------------------------------------------------------------------------- 1 | test_that("autotest aft", { 2 | skip_on_cran() 3 | set.seed(1) 4 | learner = lrn("surv.blackboost", family = "loglog") 5 | expect_learner(learner) 6 | # weights are fine for all predict types except 'distr' 7 | result = run_autotest(learner, N = 50, exclude = "weights|utf8_feature_names", check_replicable = FALSE) 8 | expect_true(result, info = result$error) 9 | }) 10 | 11 | test_that("autotest ph", { 12 | skip_on_cran() 13 | set.seed(1) 14 | learner = lrn("surv.blackboost") 15 | expect_learner(learner) 16 | # weights are fine for all predict types except 'distr' 17 | result = run_autotest(learner, N = 50, exclude = "weights|utf8_feature_names", check_replicable = FALSE) 18 | expect_true(result, info = result$error) 19 | }) 20 | 21 | test_that("ctrlpars", { 22 | skip_on_cran() 23 | set.seed(1) 24 | task = tsk("rats") 25 | learner = lrn("surv.blackboost", mstop = 99, maxpts = 24000, abseps = 0.1) 26 | p = learner$train(task, row_ids = 1:50)$predict(task, row_ids = 51:100) 27 | expect_true(inherits(p, "PredictionSurv")) 28 | }) 29 | -------------------------------------------------------------------------------- /tests/testthat/test_mboost_surv_gamboost.R: -------------------------------------------------------------------------------- 1 | test_that("autotest ph", { 2 | learner = lrn("surv.gamboost", baselearner = "bols", family = "coxph", center = TRUE) 3 | expect_learner(learner) 4 | # weights are fine for all predict types except 'distr' 5 | result = run_autotest(learner, exclude = "weights|utf8_feature_names", check_replicable = FALSE) 6 | expect_true(result, info = result$error) 7 | }) 8 | 9 | test_that("autotest aft", { 10 | learner = lrn("surv.gamboost", family = "loglog", baselearner = "bols", center = TRUE) 11 | expect_learner(learner) 12 | # weights are fine for all predict types except 'distr' 13 | result = run_autotest(learner, exclude = "weights|utf8_feature_names", check_replicable = FALSE) 14 | expect_true(result, info = result$error) 15 | }) 16 | -------------------------------------------------------------------------------- /tests/testthat/test_mboost_surv_glmboost.R: -------------------------------------------------------------------------------- 1 | test_that("autotest ph", { 2 | learner = lrn("surv.glmboost", family = "coxph") 3 | expect_learner(learner) 4 | exclude_str = "weights|utf8_feature_names|feat_single_factor|feat_all" 5 | # weights are fine for all predict types except 'distr' 6 | result = run_autotest(learner, exclude = exclude_str, check_replicable = FALSE) 7 | expect_true(result, info = result$error) 8 | }) 9 | 10 | test_that("autotest aft", { 11 | learner = lrn("surv.glmboost", family = "weibull") 12 | expect_learner(learner) 13 | exclude_str = "weights|utf8_feature_names|feat_single_factor|feat_all" 14 | # weights are fine for all predict types except 'distr' 15 | result = run_autotest(learner, exclude = exclude_str, check_replicable = FALSE) 16 | expect_true(result, info = result$error) 17 | }) 18 | 19 | test_that("can't get importance or selected features on task with factors", { 20 | task = tsk("lung") 21 | learner = lrn("surv.glmboost") 22 | learner$train(task) 23 | expect_class(learner$model, "glmboost") 24 | expect_error(learner$importance()) 25 | expect_error(learner$selected_features()) 26 | }) 27 | -------------------------------------------------------------------------------- /tests/testthat/test_mboost_surv_mboost.R: -------------------------------------------------------------------------------- 1 | test_that("autotest ph", { 2 | learner = lrn("surv.mboost", baselearner = "bols", family = "coxph", center = TRUE) 3 | expect_learner(learner) 4 | # weights are fine for all predict types except 'distr' 5 | result = run_autotest(learner, exclude = "weights|utf8_feature_names", check_replicable = FALSE) 6 | expect_true(result, info = result$error) 7 | }) 8 | 9 | test_that("autotest aft", { 10 | learner = lrn("surv.mboost", family = "loglog", baselearner = "bols", center = TRUE) 11 | expect_learner(learner) 12 | # weights are fine for all predict types except 'distr' 13 | result = run_autotest(learner, exclude = "weights|utf8_feature_names", check_replicable = FALSE) 14 | expect_true(result, info = result$error) 15 | }) 16 | -------------------------------------------------------------------------------- /tests/testthat/test_mda_regr_mars.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = lrn("regr.mars") 3 | expect_learner(learner) 4 | result = run_autotest(learner) 5 | expect_true(result, info = result$error) 6 | }) 7 | -------------------------------------------------------------------------------- /tests/testthat/test_mgcv_classif_gam.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = LearnerClassifGam$new() 3 | expect_learner(learner) 4 | result = run_autotest(learner, exclude = "utf8_feature_names") 5 | expect_true(result, info = result$error) 6 | }) 7 | -------------------------------------------------------------------------------- /tests/testthat/test_mgcv_regr_gam.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = lrn("regr.gam") 3 | expect_learner(learner) 4 | result = run_autotest(learner, exclude = "utf8_feature_names") 5 | expect_true(result, info = result$error) 6 | }) 7 | -------------------------------------------------------------------------------- /tests/testthat/test_np_dens_mixed.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = LearnerDensMixed$new() 3 | expect_learner(learner) 4 | result = run_autotest(learner) 5 | expect_true(result, info = result$error) 6 | }) 7 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_BART_surv_bart.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest surv.bart train", { 2 | learner = lrn("surv.bart") 3 | fun_list = list(BART::mc.surv.bart) 4 | exclude = c( 5 | "x.train", # handled internally 6 | "y.train", # handled internally 7 | "times", # handled internally 8 | "delta", # handled internally 9 | "x.test", # not used 10 | "xinfo", # not used 11 | "tau.num", # not used, automatically calculated from `type` and `ntype` 12 | "id", # only for `surv.bart` 13 | "importance" # added to choose the type of importance 14 | ) 15 | 16 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 17 | expect_paramtest(paramtest) 18 | }) 19 | 20 | test_that("paramset surv.bart predict", { 21 | learner = lrn("surv.bart") 22 | fun_list = list(BART:::predict.survbart, BART::surv.pre.bart) # nolint 23 | exclude = c( 24 | "object", # handled internally 25 | "newdata", # handled internally 26 | "openmp", # handled internally 27 | "times", # handled internally, used in `surv.pre.bart` 28 | "delta", # handled internally, used in `surv.pre.bart` 29 | "x.train", # handled internally, used in `surv.pre.bart` 30 | "x.test", # handled internally, used in `surv.pre.bart` 31 | "nice", # handled internally 32 | "quiet", # added to suppress print messages 33 | "which.curve" # added to choose 3rd dimension (posterior draw) for crank calculation 34 | ) 35 | 36 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "predict") 37 | expect_paramtest(paramtest) 38 | }) 39 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_C50_classif_C50.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest classif.C50 train", { 2 | learner = lrn("classif.C50") 3 | fun_list = list(C50::C5.0, C50::C5.0Control, C50::C5.0.default) 4 | predict_args = formalArgs(C50::predict.C5.0) 5 | exclude = c( 6 | "x", # handled via mlr3 7 | "y", # handled via mlr3 8 | "control", # handled via mlr3 9 | "weights" # handled via mlr3 (belongs to the task) 10 | ) 11 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 12 | expect_paramtest(paramtest) 13 | }) 14 | 15 | test_that("paramtest classif.C50 predict", { 16 | learner = lrn("classif.C50") 17 | fun_list = list(C50::predict.C5.0) 18 | predict_args = formalArgs(C50::predict.C5.0) 19 | exclude = c( 20 | "object", # handled via mlr3, 21 | "newdata", # handled via mlr3 22 | "type" # set via the `predict_type` field of the learner class 23 | ) 24 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "predict") 25 | expect_paramtest(paramtest) 26 | }) 27 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_CoxBoost_surv_coxboost.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest surv.coxboost train", { 2 | learner = lrn("surv.coxboost") 3 | fun_list = list(CoxBoost::CoxBoost) 4 | exclude = c("time", # coerced internally 5 | "status", # coerced internally 6 | "x", # coerced internally 7 | "subset", # handled by task 8 | "weights", # handled by task 9 | "stratum", # not currently supported 10 | "cmprsk", # not currently supported 11 | "coupled.strata", # not currently supported 12 | "object", # handled by self$model 13 | "newdata", # handled by task 14 | "newtime", # handled by newdata 15 | "newstatus", # handled by newdata 16 | "times", # all times returned 17 | "type" 18 | ) # handled internally 19 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 20 | expect_paramtest(paramtest) 21 | }) 22 | 23 | test_that("paramtest surv.coxboost predict", { 24 | learner = lrn("surv.coxboost") 25 | fun_list = list(CoxBoost:::predict.CoxBoost) # nolint 26 | exclude = c( 27 | "object", # mlr3 28 | "newdata", # mlr3 29 | # not implemented by author 30 | "newtime", 31 | "newstatus", 32 | "subset", # mlr3 33 | "weights", # mlr3 34 | "stratum", # mlr3 35 | "times", 36 | "type" # mlr3 37 | ) 38 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "predict") 39 | expect_paramtest(paramtest) 40 | }) 41 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_CoxBoost_surv_cv_coxboost.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest surv.cv_coxboost train", { 2 | learner = lrn("surv.cv_coxboost") 3 | fun_list = list(CoxBoost::cv.CoxBoost, CoxBoost::optimCoxBoostPenalty, CoxBoost::CoxBoost) 4 | exclude = c("time", 5 | # coerced internally 6 | "status", 7 | # coerced internally 8 | "x", 9 | # coerced internally 10 | "subset", 11 | # handled by task 12 | "weights", # handled by task 13 | "stratum", # not currently supported 14 | "cmprsk", # not currently supported 15 | "coupled.strata", # not currently supported 16 | "parallel", 17 | # handled by future 18 | "upload.x", 19 | # handled by future 20 | "multicore", # handled by future 21 | "parallel", # coerced internally 22 | "stepno" # optimised in cv.CoxBoost 23 | ) 24 | 25 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 26 | expect_paramtest(paramtest) 27 | }) 28 | 29 | test_that("paramtest surv.cv_coxboost predict", { 30 | learner = lrn("surv.cv_coxboost") 31 | fun_list = list(CoxBoost:::predict.CoxBoost) # nolint 32 | exclude = c("time", 33 | "object", # handled by mlr3 34 | "newdata", # handled by task 35 | "newtime", # handled by newdata 36 | "newstatus", # handled by newdata 37 | "type", 38 | "subset", 39 | "weights", 40 | "stratum", 41 | "times" 42 | ) 43 | 44 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "predict") 45 | expect_paramtest(paramtest) 46 | }) 47 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_Cubist_regr_cubist.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest regr.cubist train", { 2 | learner = lrn("regr.cubist") 3 | fun_list = list(Cubist::cubist, Cubist::cubistControl, Cubist:::cubist.default) # nolint 4 | exclude = c( 5 | "x", # handled by mlr3 6 | "y", # handled by mlr3 7 | "missing", # handled by mlr3 8 | "control", # handled by mlr3 9 | "weights" # handled by mlr3 10 | ) 11 | 12 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 13 | expect_paramtest(paramtest) 14 | }) 15 | 16 | test_that("paramtest regr.cubist predict", { 17 | learner = lrn("regr.cubist") 18 | fun_list = list(Cubist:::predict.cubist) # nolint 19 | exclude = c( 20 | "object", # handled by mlr3 21 | "newdata" # handled by mlr3 22 | ) 23 | 24 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "predict") 25 | expect_paramtest(paramtest) 26 | }) 27 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_FNN_classif_fnn.R: -------------------------------------------------------------------------------- 1 | # no real training phase 2 | 3 | test_that("paramtest classif.fnn predict", { 4 | learner = lrn("classif.fnn") 5 | fun = FNN::knn # replace! 6 | exclude = c( 7 | "train", # handled by mlr 8 | "test", # handled by mlr 9 | "y", # handled by mlr 10 | "cl", # this is essentially the target feature, handled by mlr 11 | "prob" # handled by mlr 12 | ) 13 | 14 | paramtest = run_paramtest(learner, fun, exclude, tag = "predict") 15 | expect_paramtest(paramtest) 16 | }) 17 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_FNN_regr_fnn.R: -------------------------------------------------------------------------------- 1 | # no real training phase 2 | 3 | test_that("paramtest regr.fnn predict", { 4 | learner = lrn("regr.fnn") 5 | fun = FNN::knn.reg # replace! 6 | exclude = c( 7 | "train", # handled by mlr 8 | "test", # handled by mlr 9 | "y" # handled by mlr 10 | ) 11 | 12 | paramtest = run_paramtest(learner, fun, exclude, tag = "predict") 13 | expect_paramtest(paramtest) 14 | }) 15 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_LiblineaR_classif_liblinear.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest classif.liblinear train", { 2 | learner = lrn("classif.liblinear") 3 | fun_list = list(LiblineaR::LiblineaR) 4 | exclude = c( 5 | "data", # handled by mlr3 6 | "target", # handled by mlr3 7 | "svr_eps" # only for regression 8 | ) 9 | 10 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 11 | expect_paramtest(paramtest) 12 | }) 13 | 14 | test_that("paramtest classif.liblinear predict", { 15 | learner = lrn("classif.liblinear") 16 | fun_list = list(LiblineaR:::predict.LiblineaR) # nolint 17 | exclude = c( 18 | "object", # handled internally 19 | "newx", # handled internally 20 | "proba", # handled internally 21 | "decisionValues" # handled internally 22 | ) 23 | 24 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "predict") 25 | expect_paramtest(paramtest) 26 | }) 27 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_LiblineaR_regr_liblinear.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest regr.liblinear train", { 2 | learner = lrn("regr.liblinear") 3 | fun_list = list(LiblineaR::LiblineaR) 4 | exclude = c( 5 | "data", # handled by mlr3 6 | "target", # handled by mlr3 7 | "epsilon", # overwritten by svr_eps 8 | "wi" # not used in regression 9 | ) 10 | 11 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 12 | expect_paramtest(paramtest) 13 | }) 14 | 15 | test_that("paramtest regr.liblinear predict", { 16 | learner = lrn("regr.liblinear") 17 | fun_list = list(LiblineaR:::predict.LiblineaR) # nolint 18 | exclude = c( 19 | "object", # handled internally 20 | "newx", # handled internally 21 | "proba", # classif only 22 | "decisionValues" # classif only 23 | ) 24 | 25 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "predict") 26 | expect_paramtest(paramtest) 27 | }) 28 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_RWeka_classif_AdaBoostM1.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest classif.AdaBoostM1 train", { 2 | learner = lrn("classif.AdaBoostM1") 3 | fun = RWeka::AdaBoostM1 4 | exclude = weka_control_args(RWeka::AdaBoostM1) 5 | # formula and data are handled via mlr3 6 | # mlr3 does not have the `control` argument because the parameters can be specified directly 7 | exclude = c("formula", "data", "control", exclude) 8 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 9 | expect_paramtest(paramtest) 10 | control_args = weka_control_args(RWeka::AdaBoostM1) 11 | expect_true(all(control_args %in% learner$param_set$ids())) 12 | }) 13 | 14 | test_that("paramtest classif.AdaBoostM1 predict", { 15 | # Here we test that the learner implements those arguments that are passed via the 16 | # control argument to RWeka::AdaBoostM1 17 | learner = lrn("classif.AdaBoostM1") 18 | exclude = c( # all handled by mlr3 19 | "object", 20 | "newdata", 21 | "type" 22 | ) 23 | paramtest = run_paramtest(learner, RWeka:::predict.Weka_classifier, exclude, tag = "predict") # nolint 24 | expect_paramtest(paramtest) 25 | }) 26 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_RWeka_classif_IBk.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest classif.IBk train", { 2 | learner = lrn("classif.IBk") 3 | fun = RWeka::IBk 4 | exclude = weka_control_args(RWeka::IBk) 5 | # formula and data are handled via mlr3 6 | # mlr3 does not have the `control` argument because the parameters can be specified directly 7 | exclude = c("formula", "data", "control", "weight", exclude) 8 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 9 | expect_paramtest(paramtest) 10 | control_args = setdiff(weka_control_args(RWeka::IBk), c("I", "F")) 11 | expect_true(all(control_args %in% learner$param_set$ids())) 12 | }) 13 | 14 | test_that("paramtest classif.IBk predict", { 15 | # Here we test that the learner implements those arguments that are passed via the 16 | # control argument to RWeka::IBk 17 | learner = lrn("classif.IBk") 18 | exclude = c( # all handled by mlr3 19 | "object", 20 | "newdata", 21 | "type" 22 | ) 23 | paramtest = run_paramtest(learner, RWeka:::predict.Weka_classifier, exclude, tag = "predict") # nolint 24 | expect_paramtest(paramtest) 25 | }) 26 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_RWeka_classif_J48.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest classif.J48 train", { 2 | learner = lrn("classif.J48") 3 | fun = RWeka::J48 4 | exclude = weka_control_args(RWeka::J48) 5 | # formula and data are handled via mlr3 6 | # mlr3 does not have the `control` argument because the parameters can be specified directly 7 | exclude = c("formula", "data", "control", exclude) 8 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 9 | expect_paramtest(paramtest) 10 | control_args = weka_control_args(RWeka::J48) 11 | expect_true(all(control_args %in% learner$param_set$ids())) 12 | }) 13 | 14 | test_that("paramtest classif.J48 predict", { 15 | # Here we test that the learner implements those arguments that are passed via the 16 | # control argument to RWeka::J48 17 | learner = lrn("classif.J48") 18 | exclude = c( # all handled by mlr3 19 | "object", 20 | "newdata", 21 | "type" 22 | ) 23 | paramtest = run_paramtest(learner, RWeka:::predict.Weka_classifier, exclude, tag = "predict") # nolint 24 | expect_paramtest(paramtest) 25 | }) 26 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_RWeka_classif_JRip.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest classif.JRip train", { 2 | learner = lrn("classif.JRip") 3 | fun = RWeka::JRip 4 | exclude = weka_control_args(RWeka::JRip) 5 | # formula and data are handled via mlr3 6 | # mlr3 does not have the `control` argument because the parameters can be specified directly 7 | exclude = c("formula", "data", "control", exclude) 8 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 9 | expect_paramtest(paramtest) 10 | control_args = weka_control_args(RWeka::JRip) 11 | expect_true(all(control_args %in% learner$param_set$ids())) 12 | }) 13 | 14 | test_that("paramtest classif.JRip predict", { 15 | # Here we test that the learner implements those arguments that are passed via the 16 | # control argument to RWeka::JRip 17 | learner = lrn("classif.JRip") 18 | exclude = c( # all handled by mlr3 19 | "object", 20 | "newdata", 21 | "type" 22 | ) 23 | paramtest = run_paramtest(learner, RWeka:::predict.Weka_classifier, exclude, tag = "predict") # nolint 24 | expect_paramtest(paramtest) 25 | }) 26 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_RWeka_classif_LMT.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest classif.LMT train", { 2 | learner = lrn("classif.LMT") 3 | fun = RWeka::LMT 4 | exclude = weka_control_args(RWeka::LMT) 5 | # formula and data are handled via mlr3 6 | # mlr3 does not have the `control` argument because the parameters can be specified directly 7 | exclude = c("formula", "data", "control", exclude) 8 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 9 | expect_paramtest(paramtest) 10 | control_args = weka_control_args(RWeka::LMT) 11 | expect_true(all(control_args %in% learner$param_set$ids())) 12 | }) 13 | 14 | test_that("paramtest classif.LMT predict", { 15 | # Here we test that the learner implements those arguments that are passed via the 16 | # control argument to RWeka::LMT 17 | learner = lrn("classif.LMT") 18 | exclude = c( # all handled by mlr3 19 | "object", 20 | "newdata", 21 | "type" 22 | ) 23 | paramtest = run_paramtest(learner, RWeka:::predict.Weka_classifier, exclude, tag = "predict") # nolint 24 | expect_paramtest(paramtest) 25 | }) 26 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_RWeka_classif_OneR.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest classif.OneR train", { 2 | learner = lrn("classif.OneR") 3 | fun = RWeka::OneR 4 | exclude = weka_control_args(RWeka::OneR) 5 | # formula and data are handled via mlr3 6 | # mlr3 does not have the `control` argument because the parameters can be specified directly 7 | exclude = c("formula", "data", "control", exclude) 8 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 9 | expect_paramtest(paramtest) 10 | control_args = weka_control_args(RWeka::OneR) 11 | expect_true(all(control_args %in% learner$param_set$ids())) 12 | }) 13 | 14 | test_that("paramtest classif.OneR predict", { 15 | # Here we test that the learner implements those arguments that are passed via the 16 | # control argument to RWeka::OneR 17 | learner = lrn("classif.OneR") 18 | exclude = c( # all handled by mlr3 19 | "object", 20 | "newdata", 21 | "type" 22 | ) 23 | paramtest = run_paramtest(learner, RWeka:::predict.Weka_classifier, exclude, tag = "predict") # nolint 24 | expect_paramtest(paramtest) 25 | }) 26 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_RWeka_classif_PART.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest classif.PART train", { 2 | learner = lrn("classif.PART") 3 | fun = RWeka::PART 4 | exclude = weka_control_args(RWeka::PART) 5 | # formula and data are handled via mlr3 6 | # mlr3 does not have the `control` argument because the parameters can be specified directly 7 | exclude = c("formula", "data", "control", exclude) 8 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 9 | expect_paramtest(paramtest) 10 | control_args = weka_control_args(RWeka::PART) 11 | expect_true(all(control_args %in% learner$param_set$ids())) 12 | }) 13 | 14 | test_that("paramtest classif.PART predict", { 15 | # Here we test that the learner implements those arguments that are passed via the 16 | # control argument to RWeka::PART 17 | learner = lrn("classif.PART") 18 | exclude = c( # all handled by mlr3 19 | "object", 20 | "newdata", 21 | "type" 22 | ) 23 | paramtest = run_paramtest(learner, RWeka:::predict.Weka_classifier, exclude, tag = "predict") # nolint 24 | expect_paramtest(paramtest) 25 | }) 26 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_RWeka_classif_bayes_net.R: -------------------------------------------------------------------------------- 1 | test_that("classif.bayes_net train", { 2 | learner = lrn("classif.bayes_net") 3 | fun = RWeka::make_Weka_classifier("weka/classifiers/bayes/BayesNet") 4 | exclude = weka_control_args(fun) 5 | # formula and data are handled via mlr3 6 | # mlr3 does not have the `control` argument because the parameters can be specified directly 7 | exclude = c("formula", "data", "control", exclude) 8 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 9 | expect_paramtest(paramtest) 10 | control_args = setdiff(weka_control_args(fun), c("N", "P", "R", "mbc", "S", "A")) 11 | expect_true(all(control_args %in% learner$param_set$ids())) 12 | }) 13 | 14 | test_that("classif.bayes_net predict", { 15 | # Here we test that the learner implements those arguments that are passed via the 16 | # control argument to RWeka::make_Weka_classifier('weka/classifiers/bayes/BayesNet') 17 | learner = lrn("classif.bayes_net") 18 | exclude = c( # all handled by mlr3 19 | "object", 20 | "newdata", 21 | "type" 22 | ) 23 | paramtest = run_paramtest(learner, RWeka:::predict.Weka_classifier, exclude, tag = "predict") # nolint 24 | expect_paramtest(paramtest) 25 | }) 26 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_RWeka_classif_decision_stump.R: -------------------------------------------------------------------------------- 1 | test_that("classif.decision_stump train", { 2 | learner = lrn("classif.decision_stump") 3 | fun = RWeka::DecisionStump 4 | exclude = weka_control_args(fun) 5 | # formula and data are handled via mlr3 6 | # mlr3 does not have the `control` argument because the parameters can be specified directly 7 | exclude = c("formula", "data", "control", exclude) 8 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 9 | expect_paramtest(paramtest) 10 | control_args = weka_control_args(fun) 11 | expect_true(all(control_args %in% learner$param_set$ids())) 12 | }) 13 | 14 | test_that("classif.decision_stump predict", { 15 | # Here we test that the learner implements those arguments that are passed via the 16 | # control argument to RWeka::DecisionStump 17 | learner = lrn("classif.decision_stump") 18 | exclude = c( # all handled by mlr3 19 | "object", 20 | "newdata", 21 | "type" 22 | ) 23 | paramtest = run_paramtest(learner, RWeka:::predict.Weka_classifier, exclude, tag = "predict") # nolint 24 | expect_paramtest(paramtest) 25 | }) 26 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_RWeka_classif_decision_table.R: -------------------------------------------------------------------------------- 1 | test_that("classif.decision_table train", { 2 | learner = lrn("classif.decision_table") 3 | fun = RWeka::make_Weka_classifier("weka/classifiers/rules/DecisionTable") 4 | exclude = weka_control_args(fun) 5 | # formula and data are handled via mlr3 6 | # mlr3 does not have the `control` argument because the parameters can be specified directly 7 | exclude = c("formula", "data", "control", "P_best", "D_best", "N_best", "S_best", exclude) 8 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 9 | expect_paramtest(paramtest) 10 | control_args = setdiff(weka_control_args(fun), c("P", "D", "N", "S")) 11 | expect_true(all(control_args %in% learner$param_set$ids())) 12 | }) 13 | 14 | test_that("classif.decision_table predict", { 15 | # Here we test that the learner implements those arguments that are passed via the 16 | # control argument to RWeka::make_Weka_classifier('weka/classifiers/rules/DecisionTable') 17 | learner = lrn("classif.decision_table") 18 | exclude = c( # all handled by mlr3 19 | "object", 20 | "newdata", 21 | "type" 22 | ) 23 | paramtest = run_paramtest(learner, RWeka:::predict.Weka_classifier, exclude, tag = "predict") # nolint 24 | expect_paramtest(paramtest) 25 | }) 26 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_RWeka_classif_kstar.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("classif.kstar train", { 4 | learner = lrn("classif.kstar") 5 | fun = RWeka::make_Weka_classifier("weka/classifiers/lazy/KStar") 6 | exclude = weka_control_args(fun) 7 | # formula and data are handled via mlr3 8 | # mlr3 does not have the `control` argument because the parameters can be specified directly 9 | exclude = c("formula", "data", "control", exclude) 10 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 11 | expect_paramtest(paramtest) 12 | control_args = weka_control_args(fun) 13 | expect_true(all(control_args %in% learner$param_set$ids())) 14 | }) 15 | 16 | test_that("classif.kstar predict", { 17 | # Here we test that the learner implements those arguments that are passed via the 18 | # control argument to RWeka::make_Weka_classifier('weka/classifiers/lazy/KStar') 19 | learner = lrn("classif.kstar") 20 | exclude = c( # all handled by mlr3 21 | "object", 22 | "newdata", 23 | "type" 24 | ) 25 | paramtest = run_paramtest(learner, RWeka:::predict.Weka_classifier, exclude, tag = "predict") # nolint 26 | expect_paramtest(paramtest) 27 | }) 28 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_RWeka_classif_logistic.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("classif.logistic train", { 4 | learner = lrn("classif.logistic") 5 | fun = RWeka::Logistic 6 | exclude = weka_control_args(fun) 7 | # formula and data are handled via mlr3 8 | # mlr3 does not have the `control` argument because the parameters can be specified directly 9 | exclude = c("formula", "data", "control", exclude) 10 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 11 | expect_paramtest(paramtest) 12 | control_args = weka_control_args(fun) 13 | expect_true(all(control_args %in% learner$param_set$ids())) 14 | }) 15 | 16 | test_that("classif.logistic predict", { 17 | # Here we test that the learner implements those arguments that are passed via the 18 | # control argument to RWeka::Logistic 19 | learner = lrn("classif.logistic") 20 | exclude = c( # all handled by mlr3 21 | "object", 22 | "newdata", 23 | "type" 24 | ) 25 | paramtest = run_paramtest(learner, RWeka:::predict.Weka_classifier, exclude, tag = "predict") # nolint 26 | expect_paramtest(paramtest) 27 | }) 28 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_RWeka_classif_multilayer_perceptron.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("classif.multilayer_perceptron train", { 4 | learner = lrn("classif.multilayer_perceptron") 5 | fun = RWeka::make_Weka_classifier("weka/classifiers/functions/MultilayerPerceptron") 6 | exclude = weka_control_args(fun) 7 | # formula and data are handled via mlr3 8 | # mlr3 does not have the `control` argument because the parameters can be specified directly 9 | exclude = c("formula", "data", "control", exclude) 10 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 11 | expect_paramtest(paramtest) 12 | control_args = setdiff(weka_control_args(fun), "G") 13 | expect_true(all(control_args %in% learner$param_set$ids())) 14 | }) 15 | 16 | test_that("classif.multilayer_perceptron predict", { 17 | # Here we test that the learner implements those arguments that are passed via the 18 | # control argument to RWeka::make_Weka_classifier('weka/classifiers/functions/MultilayerPerceptron') 19 | learner = lrn("classif.multilayer_perceptron") 20 | exclude = c( # all handled by mlr3 21 | "object", 22 | "newdata", 23 | "type" 24 | ) 25 | paramtest = run_paramtest(learner, RWeka:::predict.Weka_classifier, exclude, tag = "predict") # nolint 26 | expect_paramtest(paramtest) 27 | }) 28 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_RWeka_classif_naive_bayes_multinomial.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("classif.naive_bayes_multinomial train", { 4 | learner = lrn("classif.naive_bayes_multinomial") 5 | fun = RWeka::make_Weka_classifier("weka/classifiers/bayes/NaiveBayesMultinomial") 6 | exclude = weka_control_args(fun) 7 | # formula and data are handled via mlr3 8 | # mlr3 does not have the `control` argument because the parameters can be specified directly 9 | exclude = c("formula", "data", "control", exclude) 10 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 11 | expect_paramtest(paramtest) 12 | control_args = weka_control_args(fun) 13 | expect_true(all(control_args %in% learner$param_set$ids())) 14 | }) 15 | 16 | test_that("classif.naive_bayes_multinomial predict", { 17 | # Here we test that the learner implements those arguments that are passed via the 18 | # control argument to RWeka::make_Weka_classifier('weka/classifiers/bayes/NaiveBayesMultinomial') 19 | learner = lrn("classif.naive_bayes_multinomial") 20 | exclude = c( # all handled by mlr3 21 | "object", 22 | "newdata", 23 | "type" 24 | ) 25 | paramtest = run_paramtest(learner, RWeka:::predict.Weka_classifier, exclude, tag = "predict") # nolint 26 | expect_paramtest(paramtest) 27 | }) 28 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_RWeka_classif_naive_bayes_weka.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("classif.naive_bayes_weka train", { 4 | learner = lrn("classif.naive_bayes_weka") 5 | fun = RWeka::make_Weka_classifier("weka/classifiers/bayes/NaiveBayes") 6 | exclude = weka_control_args(fun) 7 | # formula and data are handled via mlr3 8 | # mlr3 does not have the `control` argument because the parameters can be specified directly 9 | exclude = c("formula", "data", "control", exclude) 10 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 11 | expect_paramtest(paramtest) 12 | control_args = weka_control_args(fun) 13 | expect_true(all(control_args %in% learner$param_set$ids())) 14 | }) 15 | 16 | test_that("classif.naive_bayes_weka predict", { 17 | # Here we test that the learner implements those arguments that are passed via the 18 | # control argument to RWeka::make_Weka_classifier('weka/classifiers/bayes/NaiveBayes') 19 | learner = lrn("classif.naive_bayes_weka") 20 | exclude = c( # all handled by mlr3 21 | "object", 22 | "newdata", 23 | "type" 24 | ) 25 | paramtest = run_paramtest(learner, RWeka:::predict.Weka_classifier, exclude, tag = "predict") # nolint 26 | expect_paramtest(paramtest) 27 | }) 28 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_RWeka_classif_random_forest_weka.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("classif.random_forest_weka train", { 4 | learner = lrn("classif.random_forest_weka") 5 | fun = RWeka::make_Weka_classifier("weka/classifiers/trees/RandomForest") 6 | exclude = weka_control_args(fun) 7 | # formula and data are handled via mlr3 8 | # mlr3 does not have the `control` argument because the parameters can be specified directly 9 | exclude = c("formula", "data", "control", exclude) 10 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 11 | expect_paramtest(paramtest) 12 | control_args = setdiff(weka_control_args(fun), c("attribute_importance")) 13 | expect_true(all(control_args %in% learner$param_set$ids())) 14 | }) 15 | 16 | test_that("classif.random_forest_weka predict", { 17 | # Here we test that the learner implements those arguments that are passed via the 18 | # control argument to RWeka::make_Weka_classifier('weka/classifiers/trees/RandomForest') 19 | learner = lrn("classif.random_forest_weka") 20 | exclude = c( # all handled by mlr3 21 | "object", 22 | "newdata", 23 | "type" 24 | ) 25 | paramtest = run_paramtest(learner, RWeka:::predict.Weka_classifier, exclude, tag = "predict") # nolint 26 | expect_paramtest(paramtest) 27 | }) 28 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_RWeka_classif_random_tree.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("classif.random_tree train", { 4 | learner = lrn("classif.random_tree") 5 | fun = RWeka::make_Weka_classifier("weka/classifiers/trees/RandomTree") 6 | exclude = weka_control_args(fun) 7 | # formula and data are handled via mlr3 8 | # mlr3 does not have the `control` argument because the parameters can be specified directly 9 | exclude = c("formula", "data", "control", exclude) 10 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 11 | expect_paramtest(paramtest) 12 | control_args = weka_control_args(fun) 13 | expect_true(all(control_args %in% learner$param_set$ids())) 14 | }) 15 | 16 | test_that("classif.random_tree predict", { 17 | # Here we test that the learner implements those arguments that are passed via the 18 | # control argument to RWeka::make_Weka_classifier('weka/classifiers/trees/RandomTree') 19 | learner = lrn("classif.random_tree") 20 | exclude = c( # all handled by mlr3 21 | "object", 22 | "newdata", 23 | "type" 24 | ) 25 | paramtest = run_paramtest(learner, RWeka:::predict.Weka_classifier, exclude, tag = "predict") # nolint 26 | expect_paramtest(paramtest) 27 | }) 28 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_RWeka_classif_reptree.R: -------------------------------------------------------------------------------- 1 | test_that("classif.reptree train", { 2 | learner = lrn("classif.reptree") 3 | fun = RWeka::make_Weka_classifier("weka/classifiers/trees/REPTree") 4 | exclude = weka_control_args(fun) 5 | # formula and data are handled via mlr3 6 | # mlr3 does not have the `control` argument because the parameters can be specified directly 7 | exclude = c("formula", "data", "control", exclude) 8 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 9 | expect_paramtest(paramtest) 10 | control_args = weka_control_args(fun) 11 | expect_true(all(setdiff(control_args, "R") %in% learner$param_set$ids())) 12 | }) 13 | 14 | test_that("classif.reptree predict", { 15 | # Here we test that the learner implements those arguments that are passed via the 16 | # control argument to RWeka::make_Weka_classifier('weka/classifiers/trees/REPTree') 17 | learner = lrn("classif.reptree") 18 | exclude = c( # all handled by mlr3 19 | "object", 20 | "newdata", 21 | "type" 22 | ) 23 | paramtest = run_paramtest(learner, RWeka:::predict.Weka_classifier, exclude, tag = "predict") # nolint 24 | expect_paramtest(paramtest) 25 | }) 26 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_RWeka_classif_sgd.R: -------------------------------------------------------------------------------- 1 | test_that("classif.sgd train", { 2 | learner = lrn("classif.sgd") 3 | fun = RWeka::make_Weka_classifier("weka/classifiers/functions/SGD") 4 | exclude = weka_control_args(fun) 5 | # formula and data are handled via mlr3 6 | # mlr3 does not have the `control` argument because the parameters can be specified directly 7 | exclude = c("formula", "data", "control", exclude) 8 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 9 | expect_paramtest(paramtest) 10 | control_args = weka_control_args(fun) 11 | expect_true(all(control_args %in% learner$param_set$ids())) 12 | }) 13 | 14 | test_that("classif.sgd predict", { 15 | # Here we test that the learner implements those arguments that are passed via the 16 | # control argument to RWeka::make_Weka_classifier('weka/classifiers/functions/SGD') 17 | learner = lrn("classif.sgd") 18 | exclude = c( # all handled by mlr3 19 | "object", 20 | "newdata", 21 | "type" 22 | ) 23 | paramtest = run_paramtest(learner, RWeka:::predict.Weka_classifier, exclude, tag = "predict") # nolint 24 | expect_paramtest(paramtest) 25 | }) 26 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_RWeka_classif_simple_logistic.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("classif.simple_logistic train", { 4 | learner = lrn("classif.simple_logistic") 5 | fun = RWeka::make_Weka_classifier("weka/classifiers/functions/SimpleLogistic") 6 | exclude = weka_control_args(fun) 7 | # formula and data are handled via mlr3 8 | # mlr3 does not have the `control` argument because the parameters can be specified directly 9 | exclude = c("formula", "data", "control", exclude) 10 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 11 | expect_paramtest(paramtest) 12 | control_args = weka_control_args(fun) 13 | expect_true(all(control_args %in% learner$param_set$ids())) 14 | }) 15 | 16 | test_that("classif.simple_logistic predict", { 17 | # Here we test that the learner implements those arguments that are passed via the 18 | # control argument to RWeka::make_Weka_classifier('weka/classifiers/functions/SimpleLogistic') 19 | learner = lrn("classif.simple_logistic") 20 | exclude = c( # all handled by mlr3 21 | "object", 22 | "newdata", 23 | "type" 24 | ) 25 | paramtest = run_paramtest(learner, RWeka:::predict.Weka_classifier, exclude, tag = "predict") # nolint 26 | expect_paramtest(paramtest) 27 | }) 28 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_RWeka_classif_smo.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("classif.smo train", { 4 | learner = lrn("classif.smo") 5 | fun = RWeka::SMO 6 | exclude = weka_control_args(fun) 7 | # formula and data are handled via mlr3 8 | # mlr3 does not have the `control` argument because the parameters can be specified directly 9 | exclude = c("formula", "data", "control", "E_poly", "L_poly", "C_poly", "C_logistic", "R_logistic", "M_logistic", 10 | exclude) 11 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 12 | expect_paramtest(paramtest) 13 | control_args = setdiff(weka_control_args(fun), c("E", "L", "C", "R", "M")) 14 | expect_true(all(control_args %in% learner$param_set$ids())) 15 | }) 16 | 17 | test_that("classif.smo predict", { 18 | # Here we test that the learner implements those arguments that are passed via the 19 | # control argument to RWeka::SMO 20 | learner = lrn("classif.smo") 21 | exclude = c( # all handled by mlr3 22 | "object", 23 | "newdata", 24 | "type" 25 | ) 26 | paramtest = run_paramtest(learner, RWeka:::predict.Weka_classifier, exclude, tag = "predict") # nolint 27 | expect_paramtest(paramtest) 28 | }) 29 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_RWeka_classif_voted_perceptron.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("classif.voted_perceptron train", { 4 | learner = lrn("classif.voted_perceptron") 5 | fun = RWeka::make_Weka_classifier("weka/classifiers/functions/VotedPerceptron") 6 | exclude = weka_control_args(fun) 7 | # formula and data are handled via mlr3 8 | # mlr3 does not have the `control` argument because the parameters can be specified directly 9 | exclude = c("formula", "data", "control", exclude) 10 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 11 | expect_paramtest(paramtest) 12 | control_args = weka_control_args(fun) 13 | expect_true(all(control_args %in% learner$param_set$ids())) 14 | }) 15 | 16 | test_that("classif.voted_perceptron predict", { 17 | # Here we test that the learner implements those arguments that are passed via the 18 | # control argument to RWeka::make_Weka_classifier('weka/classifiers/functions/VotedPerceptron') 19 | learner = lrn("classif.voted_perceptron") 20 | exclude = c( # all handled by mlr3 21 | "object", 22 | "newdata", 23 | "type" 24 | ) 25 | paramtest = run_paramtest(learner, RWeka:::predict.Weka_classifier, exclude, tag = "predict") # nolint 26 | expect_paramtest(paramtest) 27 | }) 28 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_RWeka_regr_IBk.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("paramtest regr.IBk train", { 4 | learner = lrn("regr.IBk") 5 | fun = RWeka::IBk 6 | exclude = weka_control_args(RWeka::IBk) 7 | # formula and data are handled via mlr3 8 | # mlr3 does not have the `control` argument because the parameters can be specified directly 9 | exclude = c("formula", "data", "control", "weight", exclude) 10 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 11 | expect_paramtest(paramtest) 12 | control_args = setdiff(weka_control_args(RWeka::IBk), c("I", "F")) 13 | expect_true(all(control_args %in% learner$param_set$ids())) 14 | }) 15 | 16 | test_that("paramtest regr.IBk predict", { 17 | # Here we test that the learner implements those arguments that are passed via the 18 | # control argument to RWeka::IBk 19 | learner = lrn("regr.IBk") 20 | exclude = c( # all handled by mlr3 21 | "object", 22 | "newdata", 23 | "type" 24 | ) 25 | paramtest = run_paramtest(learner, RWeka:::predict.Weka_classifier, exclude, tag = "predict") # nolint 26 | expect_paramtest(paramtest) 27 | }) 28 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_RWeka_regr_M5Rules.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest regr.M5Rules train", { 2 | learner = lrn("regr.M5Rules") 3 | fun = RWeka::M5Rules 4 | exclude = weka_control_args(RWeka::M5Rules) 5 | # formula and data are handled via mlr3 6 | # mlr3 does not have the `control` argument because the parameters can be specified directly 7 | exclude = c("formula", "data", "control", exclude) 8 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 9 | expect_paramtest(paramtest) 10 | control_args = weka_control_args(RWeka::M5Rules) 11 | expect_true(all(control_args %in% learner$param_set$ids())) 12 | }) 13 | 14 | test_that("paramtest regr.M5Rules predict", { 15 | # Here we test that the learner implements those arguments that are passed via the 16 | # control argument to RWeka::M5Rules 17 | learner = lrn("regr.M5Rules") 18 | exclude = c( # all handled by mlr3 19 | "object", 20 | "newdata", 21 | "type" 22 | ) 23 | paramtest = run_paramtest(learner, RWeka:::predict.Weka_classifier, exclude, tag = "predict") # nolint 24 | expect_paramtest(paramtest) 25 | }) 26 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_RWeka_regr_decision_stump.R: -------------------------------------------------------------------------------- 1 | test_that("regr.decision_stump train", { 2 | learner = lrn("regr.decision_stump") 3 | fun = RWeka::DecisionStump 4 | exclude = weka_control_args(fun) 5 | # formula and data are handled via mlr3 6 | # mlr3 does not have the `control` argument because the parameters can be specified directly 7 | exclude = c("formula", "data", "control", exclude) 8 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 9 | expect_paramtest(paramtest) 10 | control_args = weka_control_args(fun) 11 | expect_true(all(control_args %in% learner$param_set$ids())) 12 | }) 13 | 14 | test_that("regr.decision_stump predict", { 15 | # Here we test that the learner implements those arguments that are passed via the 16 | # control argument to RWeka::DecisionStump 17 | learner = lrn("regr.decision_stump") 18 | exclude = c( # all handled by mlr3 19 | "object", 20 | "newdata", 21 | "type" 22 | ) 23 | paramtest = run_paramtest(learner, RWeka:::predict.Weka_classifier, exclude, tag = "predict") # nolint 24 | expect_paramtest(paramtest) 25 | }) 26 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_RWeka_regr_decision_table.R: -------------------------------------------------------------------------------- 1 | test_that("regr.decision_table train", { 2 | learner = lrn("regr.decision_table") 3 | fun = RWeka::make_Weka_classifier("weka/classifiers/rules/DecisionTable") 4 | exclude = weka_control_args(fun) 5 | # formula and data are handled via mlr3 6 | # mlr3 does not have the `control` argument because the parameters can be specified directly 7 | exclude = c("formula", "data", "control", "P_best", "D_best", "N_best", "S_best", exclude) 8 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 9 | expect_paramtest(paramtest) 10 | control_args = setdiff(weka_control_args(fun), c("P", "D", "N", "S")) 11 | expect_true(all(control_args %in% learner$param_set$ids())) 12 | }) 13 | 14 | test_that("regr.decision_table predict", { 15 | # Here we test that the learner implements those arguments that are passed via the 16 | # control argument to RWeka::make_Weka_classifier('weka/classifiers/rules/DecisionTable') 17 | learner = lrn("regr.decision_table") 18 | exclude = c( # all handled by mlr3 19 | "object", 20 | "newdata", 21 | "type" 22 | ) 23 | paramtest = run_paramtest(learner, RWeka:::predict.Weka_classifier, exclude, tag = "predict") # nolint 24 | expect_paramtest(paramtest) 25 | }) 26 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_RWeka_regr_gaussian_processes.R: -------------------------------------------------------------------------------- 1 | test_that("regr.gaussian_processes train", { 2 | learner = lrn("regr.gaussian_processes") 3 | fun = RWeka::make_Weka_classifier("weka/classifiers/functions/GaussianProcesses") 4 | exclude = weka_control_args(fun) 5 | # formula and data are handled via mlr3 6 | # mlr3 does not have the `control` argument because the parameters can be specified directly 7 | exclude = c("formula", "data", "control", "E_poly", "L_poly", "C_poly", exclude) 8 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 9 | expect_paramtest(paramtest) 10 | control_args = setdiff(weka_control_args(fun), c("E", "C")) 11 | expect_true(all(control_args %in% learner$param_set$ids())) 12 | }) 13 | 14 | test_that("regr.gaussian_processes predict", { 15 | # Here we test that the learner implements those arguments that are passed via the 16 | # control argument to RWeka::make_Weka_classifier('weka/classifiers/functions/GaussianProcesses') 17 | learner = lrn("regr.gaussian_processes") 18 | exclude = c( # all handled by mlr3 19 | "object", 20 | "newdata", 21 | "type" 22 | ) 23 | paramtest = run_paramtest(learner, RWeka:::predict.Weka_classifier, exclude, tag = "predict") # nolint 24 | expect_paramtest(paramtest) 25 | }) 26 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_RWeka_regr_kstar.R: -------------------------------------------------------------------------------- 1 | test_that("regr.kstar train", { 2 | learner = lrn("regr.kstar") 3 | fun = RWeka::make_Weka_classifier("weka/classifiers/lazy/KStar") 4 | exclude = weka_control_args(fun) 5 | # formula and data are handled via mlr3 6 | # mlr3 does not have the `control` argument because the parameters can be specified directly 7 | exclude = c("formula", "data", "control", exclude) 8 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 9 | expect_paramtest(paramtest) 10 | control_args = weka_control_args(fun) 11 | expect_true(all(control_args %in% learner$param_set$ids())) 12 | }) 13 | 14 | test_that("regr.kstar predict", { 15 | # Here we test that the learner implements those arguments that are passed via the 16 | # control argument to RWeka::make_Weka_classifier('weka/classifiers/lazy/KStar') 17 | learner = lrn("regr.kstar") 18 | exclude = c( # all handled by mlr3 19 | "object", 20 | "newdata", 21 | "type" 22 | ) 23 | paramtest = run_paramtest(learner, RWeka:::predict.Weka_classifier, exclude, tag = "predict") # nolint 24 | expect_paramtest(paramtest) 25 | }) 26 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_RWeka_regr_linear_regression.R: -------------------------------------------------------------------------------- 1 | test_that("regr.linear_regression train", { 2 | learner = lrn("regr.linear_regression") 3 | fun = RWeka::LinearRegression 4 | exclude = weka_control_args(fun) 5 | # formula and data are handled via mlr3 6 | # mlr3 does not have the `control` argument because the parameters can be specified directly 7 | exclude = c("formula", "data", "control", exclude) 8 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 9 | expect_paramtest(paramtest) 10 | control_args = weka_control_args(fun) 11 | expect_true(all(control_args %in% learner$param_set$ids())) 12 | }) 13 | 14 | test_that("regr.linear_regression predict", { 15 | # Here we test that the learner implements those arguments that are passed via the 16 | # control argument to RWeka::LinearRegression 17 | learner = lrn("regr.linear_regression") 18 | exclude = c( # all handled by mlr3 19 | "object", 20 | "newdata", 21 | "type" 22 | ) 23 | paramtest = run_paramtest(learner, RWeka:::predict.Weka_classifier, exclude, tag = "predict") # nolint 24 | expect_paramtest(paramtest) 25 | }) 26 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_RWeka_regr_m5p.R: -------------------------------------------------------------------------------- 1 | test_that("regr.m5p train", { 2 | learner = lrn("regr.m5p") 3 | fun = RWeka::M5P 4 | exclude = weka_control_args(RWeka::M5P) 5 | # formula and data are handled via mlr3 6 | # mlr3 does not have the `control` argument because the parameters can be specified directly 7 | exclude = c("formula", "data", "control", exclude) 8 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 9 | expect_paramtest(paramtest) 10 | control_args = weka_control_args(RWeka::M5P) 11 | expect_true(all(control_args %in% learner$param_set$ids())) 12 | }) 13 | 14 | test_that("regr.m5p predict", { 15 | # Here we test that the learner implements those arguments that are passed via the 16 | # control argument to RWeka::M5P 17 | learner = lrn("regr.m5p") 18 | exclude = c( # all handled by mlr3 19 | "object", 20 | "newdata", 21 | "type" 22 | ) 23 | paramtest = run_paramtest(learner, RWeka:::predict.Weka_classifier, exclude, tag = "predict") # nolint 24 | expect_paramtest(paramtest) 25 | }) 26 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_RWeka_regr_multilayer_perceptron.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("regr.multilayer_perceptron train", { 4 | learner = lrn("regr.multilayer_perceptron") 5 | fun = RWeka::make_Weka_classifier("weka/classifiers/functions/MultilayerPerceptron") 6 | exclude = weka_control_args(fun) 7 | # formula and data are handled via mlr3 8 | # mlr3 does not have the `control` argument because the parameters can be specified directly 9 | exclude = c("formula", "data", "control", exclude) 10 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 11 | expect_paramtest(paramtest) 12 | control_args = setdiff(weka_control_args(fun), "G") 13 | expect_true(all(control_args %in% learner$param_set$ids())) 14 | }) 15 | 16 | test_that("regr.multilayer_perceptron predict", { 17 | # Here we test that the learner implements those arguments that are passed via the 18 | # control argument to RWeka::make_Weka_classifier('weka/classifiers/functions/MultilayerPerceptron') 19 | learner = lrn("regr.multilayer_perceptron") 20 | exclude = c( # all handled by mlr3 21 | "object", 22 | "newdata", 23 | "type" 24 | ) 25 | paramtest = run_paramtest(learner, RWeka:::predict.Weka_classifier, exclude, tag = "predict") # nolint 26 | expect_paramtest(paramtest) 27 | }) 28 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_RWeka_regr_random_forest_weka.R: -------------------------------------------------------------------------------- 1 | test_that("regr.random_forest_weka train", { 2 | learner = lrn("regr.random_forest_weka") 3 | fun = RWeka::make_Weka_classifier("weka/classifiers/trees/RandomForest") 4 | exclude = weka_control_args(fun) 5 | # formula and data are handled via mlr3 6 | # mlr3 does not have the `control` argument because the parameters can be specified directly 7 | exclude = c("formula", "data", "control", exclude) 8 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 9 | expect_paramtest(paramtest) 10 | control_args = setdiff(weka_control_args(fun), c("attribute_importance")) 11 | expect_true(all(control_args %in% learner$param_set$ids())) 12 | }) 13 | 14 | test_that("regr.random_forest_weka predict", { 15 | # Here we test that the learner implements those arguments that are passed via the 16 | # control argument to RWeka::make_Weka_classifier('weka/classifiers/trees/RandomForest') 17 | learner = lrn("regr.random_forest_weka") 18 | exclude = c( # all handled by mlr3 19 | "object", 20 | "newdata", 21 | "type" 22 | ) 23 | paramtest = run_paramtest(learner, RWeka:::predict.Weka_classifier, exclude, tag = "predict") # nolint 24 | expect_paramtest(paramtest) 25 | }) 26 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_RWeka_regr_random_tree.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("classif.random_tree train", { 4 | learner = lrn("regr.random_tree") 5 | fun = RWeka::make_Weka_classifier("weka/classifiers/trees/RandomTree") 6 | exclude = weka_control_args(fun) 7 | # formula and data are handled via mlr3 8 | # mlr3 does not have the `control` argument because the parameters can be specified directly 9 | exclude = c("formula", "data", "control", exclude) 10 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 11 | expect_paramtest(paramtest) 12 | control_args = weka_control_args(fun) 13 | expect_true(all(control_args %in% learner$param_set$ids())) 14 | }) 15 | 16 | test_that("regr.random_tree predict", { 17 | # Here we test that the learner implements those arguments that are passed via the 18 | # control argument to RWeka::make_Weka_classifier('weka/classifiers/trees/RandomTree') 19 | learner = lrn("regr.random_tree") 20 | exclude = c( # all handled by mlr3 21 | "object", 22 | "newdata", 23 | "type" 24 | ) 25 | paramtest = run_paramtest(learner, RWeka:::predict.Weka_classifier, exclude, tag = "predict") # nolint 26 | expect_paramtest(paramtest) 27 | }) 28 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_RWeka_regr_reptree.R: -------------------------------------------------------------------------------- 1 | test_that("regr.reptree train", { 2 | learner = lrn("regr.reptree") 3 | fun = RWeka::make_Weka_classifier("weka/classifiers/trees/REPTree") 4 | exclude = weka_control_args(fun) 5 | # formula and data are handled via mlr3 6 | # mlr3 does not have the `control` argument because the parameters can be specified directly 7 | exclude = c("formula", "data", "control", exclude) 8 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 9 | expect_paramtest(paramtest) 10 | control_args = weka_control_args(fun) 11 | expect_true(all(setdiff(control_args, "R") %in% learner$param_set$ids())) 12 | }) 13 | 14 | test_that("regr.reptree predict", { 15 | # Here we test that the learner implements those arguments that are passed via the 16 | # control argument to RWeka::make_Weka_classifier('weka/classifiers/trees/REPTree') 17 | learner = lrn("regr.reptree") 18 | exclude = c( # all handled by mlr3 19 | "object", 20 | "newdata", 21 | "type" 22 | ) 23 | paramtest = run_paramtest(learner, RWeka:::predict.Weka_classifier, exclude, tag = "predict") # nolint 24 | expect_paramtest(paramtest) 25 | }) 26 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_RWeka_regr_sgd.R: -------------------------------------------------------------------------------- 1 | test_that("regr.sgd train", { 2 | learner = lrn("regr.sgd") 3 | fun = RWeka::make_Weka_classifier("weka/classifiers/functions/SGD") 4 | exclude = weka_control_args(fun) 5 | # formula and data are handled via mlr3 6 | # mlr3 does not have the `control` argument because the parameters can be specified directly 7 | exclude = c("formula", "data", "control", exclude) 8 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 9 | expect_paramtest(paramtest) 10 | control_args = weka_control_args(fun) 11 | expect_true(all(control_args %in% learner$param_set$ids())) 12 | }) 13 | 14 | test_that("regr.sgd predict", { 15 | # Here we test that the learner implements those arguments that are passed via the 16 | # control argument to RWeka::make_Weka_classifier('weka/classifiers/functions/SGD') 17 | learner = lrn("regr.sgd") 18 | exclude = c( # all handled by mlr3 19 | "object", 20 | "newdata", 21 | "type" 22 | ) 23 | paramtest = run_paramtest(learner, RWeka:::predict.Weka_classifier, exclude, tag = "predict") # nolint 24 | expect_paramtest(paramtest) 25 | }) 26 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_RWeka_regr_simple_linear_regression.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("regr.simple_linear_regression train", { 4 | learner = lrn("regr.simple_linear_regression") 5 | fun = RWeka::make_Weka_classifier("weka/classifiers/functions/SimpleLinearRegression") 6 | exclude = weka_control_args(fun) 7 | # formula and data are handled via mlr3 8 | # mlr3 does not have the `control` argument because the parameters can be specified directly 9 | exclude = c("formula", "data", "control", exclude) 10 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 11 | expect_paramtest(paramtest) 12 | control_args = weka_control_args(fun) 13 | expect_true(all(control_args %in% learner$param_set$ids())) 14 | }) 15 | 16 | test_that("regr.simple_linear_regression predict", { 17 | # Here we test that the learner implements those arguments that are passed via the 18 | # control argument to RWeka::make_Weka_classifier('weka/classifiers/functions/SimpleLinearRegression') 19 | learner = lrn("regr.simple_linear_regression") 20 | exclude = c( # all handled by mlr3 21 | "object", 22 | "newdata", 23 | "type" 24 | ) 25 | paramtest = run_paramtest(learner, RWeka:::predict.Weka_classifier, exclude, tag = "predict") # nolint 26 | expect_paramtest(paramtest) 27 | }) 28 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_RWeka_regr_smo_reg.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("regr.smo_reg train", { 4 | learner = lrn("regr.smo_reg") 5 | fun = RWeka::make_Weka_classifier("weka/classifiers/functions/SMOreg") 6 | exclude = weka_control_args(fun) 7 | # formula and data are handled via mlr3 8 | # mlr3 does not have the `control` argument because the parameters can be specified directly 9 | exclude = c("formula", "data", "control", "T_improved", "V_improved", "P_improved", "L_improved", "W_improved", 10 | "C_poly", "E_poly", "L_poly", exclude) 11 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 12 | expect_paramtest(paramtest) 13 | control_args = setdiff(weka_control_args(fun), c("T", "V", "P", "L", "W", "C", "E")) 14 | expect_true(all(control_args %in% learner$param_set$ids())) 15 | }) 16 | 17 | test_that("regr.smo_reg predict", { 18 | # Here we test that the learner implements those arguments that are passed via the 19 | # control argument to RWeka::make_Weka_classifier('weka/classifiers/functions/SMOreg') 20 | learner = lrn("regr.smo_reg") 21 | exclude = c( # all handled by mlr3 22 | "object", 23 | "newdata", 24 | "type" 25 | ) 26 | paramtest = run_paramtest(learner, RWeka:::predict.Weka_classifier, exclude, tag = "predict") # nolint 27 | expect_paramtest(paramtest) 28 | }) 29 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_abess_classif_abess.R: -------------------------------------------------------------------------------- 1 | test_that("regr.abess predict", { 2 | learner = lrn("regr.abess") 3 | fun = predict # nolint 4 | exclude = c( 5 | "support.size", # handled by mlr3 6 | "type", # only support prob 7 | "newx", # handled by mlr3 8 | "object" # handled by mlr3 9 | ) 10 | paramtest = run_paramtest(learner, fun, exclude, tag = 'perdict') 11 | expect_paramtest(paramtest) 12 | }) 13 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_abess_regr_abess.R: -------------------------------------------------------------------------------- 1 | test_that("regr.abess predict", { 2 | learner = lrn("regr.abess") 3 | fun = predict # nolint 4 | exclude = c( 5 | "support.size", # handled by mlr3 6 | "type", # regr needn't type 7 | "newx", # handled by mlr3 8 | "object" # handled by mlr3 9 | ) 10 | paramtest = run_paramtest(learner, fun, exclude, tag = 'perdict') 11 | expect_paramtest(paramtest) 12 | }) 13 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_catboost_classif_catboost.R: -------------------------------------------------------------------------------- 1 | # It does not make sense to test the parameters because they are not accessible within 2 | # R but only listed online: https://catboost.ai/docs/concepts/r-reference_catboost-train.html 3 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_catboost_regr_catboost.R: -------------------------------------------------------------------------------- 1 | # It does not make sense to test the parameters because they are not accessible within 2 | # R but only listed online: https://catboost.ai/docs/concepts/r-reference_catboost-train.html 3 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_earth_classif_earth.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest classif.earth train", { 2 | learner = lrn("classif.earth") 3 | fun_list = list(earth:::earth.default, earth:::earth.fit) # nolint 4 | 5 | exclude = c( 6 | "x", # handled internally 7 | "y", # handled internally 8 | "subset", # handled internally 9 | "weights", # handled internally 10 | "na.action", # only one option 11 | "glm", # handled internally 12 | "object", # handled internally 13 | "Object" # only used when called by update.earth 14 | ) 15 | 16 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 17 | expect_paramtest(paramtest) 18 | }) 19 | 20 | test_that("paramtest classif.earth train", { 21 | learner = lrn("classif.earth") 22 | fun_list = earth:::predict.earth # nolint 23 | 24 | exclude = c( 25 | "object", # handled internally 26 | "newdata", # handled internally 27 | "type", # handled internally 28 | "level", # unused 29 | "interval", # handled internally 30 | "thresh", # not implemented by author 31 | "trace" # not implemented by author 32 | ) 33 | 34 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "predict") 35 | expect_paramtest(paramtest) 36 | }) 37 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_earth_regr_earth.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest regr.earth train", { 2 | learner = lrn("regr.earth") 3 | fun = earth:::earth.default # nolint 4 | fun_list = list(earth:::earth.default, earth:::earth.fit) # nolint 5 | 6 | exclude = c( 7 | "x", # handled internally 8 | "y", # handled internally 9 | "subset", # handled internally 10 | "weights", # handled internally 11 | "na.action", # only one option 12 | "glm", # handled internally 13 | "Object" # only used when called by update.earth 14 | ) 15 | 16 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 17 | expect_paramtest(paramtest) 18 | }) 19 | 20 | test_that("paramtest regr.earth predict", { 21 | learner = lrn("regr.earth") 22 | fun = earth:::earth.default 23 | fun_list = list(earth:::predict.earth) 24 | 25 | exclude = c( 26 | "object", # handled internally 27 | "newdata", # handled internally 28 | "type", # handled internally 29 | "level", # unused 30 | "interval", # handled internally 31 | "thresh", # not implemented by author 32 | "trace" # not implemented by author 33 | ) 34 | 35 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "predict") 36 | expect_paramtest(paramtest) 37 | }) 38 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_flexsurv_surv_flexible.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest surv.flexible train", { 2 | task = tsk("rats") 3 | learner = lrn("surv.flexible") 4 | fun_list = list(flexsurv::flexsurvspline, flexsurv::flexsurvreg, survival::survreg.control) 5 | exclude = c( 6 | "data", # handled internally 7 | "weights", # handle by task 8 | "subset", # handle by task 9 | "iter.max", # identical to maxiter 10 | "formula", # Not implemented by the creator 11 | "anc", # not implemented by the creator 12 | "na.action", # not implemented by the creator 13 | "dist", # not implemented by the creator 14 | "dfns", # not implemented by the creator 15 | "aux", # not implemented by the creator 16 | "integ.opts", # not implemented by the creator 17 | "sr.control", # not implemented by the creator 18 | "hessian", # not implemented by the creator 19 | "hess.control" # not implemented by the creator 20 | ) 21 | 22 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 23 | expect_paramtest(paramtest) 24 | }) 25 | 26 | # no predict time parameters 27 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_gbm_classif_gbm.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest classif.gbm train", { 2 | learner = lrn("classif.gbm") 3 | fun = gbm::gbm 4 | exclude = c( 5 | "formula", # handled by mlr3 6 | "data", # handled by mlr3 7 | "weights", # handled by mlr3 8 | "class.stratify.cv", # handled by mlr3 9 | "single.tree", # we don't allow for single trees 10 | "newdata", # handled by mlr3 11 | "object", # handled by mlr3 12 | "type" # we only allow type "link" to get the response prediction 13 | ) 14 | 15 | paramtest = run_paramtest(learner, fun, exclude, "train") 16 | expect_paramtest(paramtest) 17 | }) 18 | 19 | test_that("paramtest classif.gbm train", { 20 | learner = lrn("classif.gbm") 21 | fun = gbm::predict.gbm 22 | exclude = c( 23 | "formula", # handled by mlr3 24 | "data", # handled by mlr3 25 | "weights", # handled by mlr3 26 | "class.stratify.cv", # handled by mlr3 27 | "single.tree", # we don't allow for single trees 28 | "newdata", # handled by mlr3 29 | "object", # handled by mlr3 30 | "type" # we only allow type "link" to get the response prediction 31 | ) 32 | 33 | paramtest = run_paramtest(learner, fun, exclude, "predict") 34 | expect_paramtest(paramtest) 35 | }) 36 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_gbm_regr_gbm.R: -------------------------------------------------------------------------------- 1 | test_that("regr.gbm", { 2 | learner = lrn("regr.gbm") 3 | fun = gbm::gbm 4 | exclude = c( 5 | "formula", # handled by mlr3 6 | "data", # handled by mlr3 7 | "weights", # handled by mlr3 8 | "class.stratify.cv", # handled by mlr3 9 | "single.tree", # we don't allow for single trees 10 | "newdata", # handled by mlr3 11 | "object", # handled by mlr3 12 | "type" # we only allow type "link" to get the response prediction 13 | ) 14 | 15 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 16 | expect_paramtest(paramtest) 17 | }) 18 | 19 | test_that("regr.gbm", { 20 | learner = lrn("regr.gbm") 21 | fun = gbm::predict.gbm 22 | exclude = c( 23 | "formula", # handled by mlr3 24 | "data", # handled by mlr3 25 | "weights", # handled by mlr3 26 | "class.stratify.cv", # handled by mlr3 27 | "single.tree", # we don't allow for single trees 28 | "newdata", # handled by mlr3 29 | "object", # handled by mlr3 30 | "type" # we only allow type "link" to get the response prediction 31 | ) 32 | 33 | paramtest = run_paramtest(learner, fun, exclude, tag = "predict") 34 | expect_paramtest(paramtest) 35 | }) 36 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_gbm_surv_gbm.R: -------------------------------------------------------------------------------- 1 | test_that("surv.gbm", { 2 | learner = lrn("surv.gbm") 3 | fun = fun_list = gbm::gbm 4 | exclude = c( 5 | "formula", # handled by mlr3 6 | "data", # handled by mlr3 7 | "weights", # handled by mlr3 8 | "class.stratify.cv", # handled by mlr3 9 | "single.tree" # we don't allow for single trees 10 | ) 11 | 12 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 13 | expect_paramtest(paramtest) 14 | }) 15 | 16 | test_that("surv.gbm", { 17 | learner = lrn("surv.gbm") 18 | fun = fun_list = list(gbm::predict.gbm) 19 | exclude = c( 20 | "newdata", # handled by mlr3 21 | "object", # handled by mlr3 22 | "type" # we only allow type "link" to get the response prediction 23 | ) 24 | 25 | paramtest = run_paramtest(learner, fun, exclude, tag = "predict") 26 | expect_paramtest(paramtest) 27 | }) 28 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_glmnet_surv_cv_glmnet.R: -------------------------------------------------------------------------------- 1 | test_that("surv.cv_glmnet", { 2 | learner = lrn("surv.cv_glmnet") 3 | fun = list(glmnet::cv.glmnet, glmnet::glmnet.control, glmnet::glmnet) 4 | exclude = c( 5 | "x", # handled by mlr3 6 | "y", # handled by mlr3 7 | "weights", # handled by mlr3 8 | "itrace", # supported via param trace.it 9 | "factory", # only used in scripts, no effect within mlr3 10 | "family", # handled by mlr3 11 | "offset" # handled by mlr3 12 | ) 13 | 14 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 15 | expect_paramtest(paramtest) 16 | }) 17 | 18 | test_that("predict surv.cv_glmnet", { 19 | learner = lrn("surv.cv_glmnet") 20 | fun = glmnet:::predict.cv.glmnet # nolint 21 | exclude = c( 22 | "object", # handled via mlr3 23 | "newx", # handled via mlr3 24 | "predict.gamma", # renamed from gamma 25 | "offset", # for distr prediction 26 | "newoffset", # handled by mlr3 27 | "stype", # for distr prediction 28 | "ctype", # for distr prediction 29 | "use_pred_offset" # for using the offset during prediction 30 | ) 31 | 32 | paramtest = run_paramtest(learner, fun, exclude, tag = "predict") 33 | expect_paramtest(paramtest) 34 | }) 35 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_glmnet_surv_glmnet.R: -------------------------------------------------------------------------------- 1 | test_that("surv.glmnet", { 2 | learner = lrn("surv.glmnet") 3 | fun = list(glmnet::glmnet, glmnet::cv.glmnet, glmnet::glmnet.control) 4 | exclude = c( 5 | "x", # handled by mlr3 6 | "y", # handled by mlr3 7 | "weights", # handled by mlr3 8 | "nfolds", # not used by learner 9 | "foldid", # not used by learner 10 | "family", # only coxnet available 11 | "type.gaussian", # not used by learner 12 | "type.measure", # only used by cv.glmnet 13 | "standardize.response", # for 'mgaussian' only 14 | "itrace", # supported via param trace.it 15 | "factory", # only used in scripts, no effect within mlr3 16 | "offset" # handled by mlr3 17 | ) 18 | 19 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 20 | expect_paramtest(paramtest) 21 | }) 22 | 23 | test_that("predict surv.glmnet", { 24 | learner = lrn("surv.glmnet") 25 | fun = glmnet::predict.glmnet 26 | exclude = c( 27 | "object", # handled via mlr3 28 | "newx", # handled via mlr3 29 | "type", # handled via mlr3 30 | "predict.gamma", # renamed from gamma 31 | "offset", # for distr prediction 32 | "stype", # for distr prediction 33 | "ctype", # for distr prediction 34 | "newoffset", # handled by mlr3 35 | "use_pred_offset" # for using the offset during prediction 36 | ) 37 | 38 | paramtest = run_paramtest(learner, fun, exclude, tag = "predict") 39 | expect_paramtest(paramtest) 40 | }) 41 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_gss_dens_spline.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest dens.spline train", { 2 | learner = lrn("dens.spline") 3 | fun = gss::ssden 4 | exclude = c( 5 | "formula", # handled internally 6 | "data", # handled internally 7 | "subset" # handled by task 8 | ) 9 | 10 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 11 | expect_paramtest(paramtest) 12 | }) 13 | 14 | # no predict parameters 15 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_ks_dens_kde_ks.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest dens.kde_ks train", { 2 | learner = lrn("dens.kde_ks") 3 | fun = ks::kde 4 | exclude = c( 5 | "x", # handled internally 6 | "eval.points" # handled by predict 7 | ) 8 | 9 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 10 | expect_paramtest(paramtest) 11 | }) 12 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_locfit_dens_locfit.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest dens.locfit train", { 2 | learner = lrn("dens.locfit") 3 | # density.lf calls locfit.raw internally (this is where the ... go) 4 | fun_list = list(locfit::density.lf, locfit::locfit.raw) 5 | exclude = c( 6 | "x", # handled in predict 7 | "y", # only for regressoin 8 | "n", # ev used instead 9 | "ev", # handled in predict 10 | "family", # always density 11 | "deg", # deprecated 12 | "alpha", # deprecated 13 | "scale", # deprecated 14 | "sty", # deprecated 15 | "acri", # deprecated 16 | "geth", # docs say `don't use` 17 | "window", # equialent to `kern` argument 18 | "cens", # hazard rate or censored regressoin 19 | "base", # regression 20 | # not implemented by the author (can be upon user request) 21 | "debug", 22 | "xlim", 23 | "deriv", 24 | "weights", 25 | "basis", 26 | "dc" 27 | ) 28 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 29 | expect_paramtest(paramtest) 30 | }) 31 | 32 | # no predict time parameters 33 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_logspline_dens_logspline.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest dens.logspline", { 2 | learner = lrn("dens.logspline") 3 | fun = logspline::logspline 4 | exclude = c( 5 | "x" # handled internally 6 | ) 7 | 8 | paramtest = run_paramtest(learner, fun, exclude) 9 | expect_paramtest(paramtest) 10 | }) 11 | 12 | # no predict time parameters 13 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_mboost_classif_gamboost.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest classif.gamboost train", { 2 | learner = lrn("classif.gamboost") 3 | fun_list = list(mboost::gamboost, mboost::boost_control) 4 | exclude = c( 5 | "formula", # handled via mlr3 6 | "data", # handled via mlr3 7 | "weights", # handled via mlr3 8 | "control", # handled to mboost::boost_control 9 | "center", # (mboost_control) depreacated 10 | "custom.family", # Provide a custom family 11 | "type", # mboost::Binomial 12 | "link", # mboost::Binomial 13 | "offset" 14 | ) 15 | 16 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 17 | expect_paramtest(paramtest) 18 | }) 19 | 20 | test_that("paramtest classif.gamboost predict", { 21 | learner = lrn("classif.gamboost") 22 | fun_list = list(mboost:::predict.mboost) # nolint 23 | 24 | exclude = c( 25 | "object", # mlr3 26 | "newdata", # mlr3 27 | "type", # mlr3 28 | "which", 29 | "aggregate" 30 | ) 31 | 32 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "predict") 33 | expect_paramtest(paramtest) 34 | }) 35 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_mboost_classif_glmboost.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest classif.glmboost train", { 2 | learner = lrn("classif.glmboost") 3 | fun_list = list(mboost:::glmboost.formula, mboost::boost_control) # nolint 4 | exclude = c( 5 | "formula", # handled via mlr3 6 | "data", # handled via mlr3 7 | "weights", # handled via mlr3 8 | "control", # handled to mboost::boost_control 9 | "center", # deprecated 10 | "custom.family", # provide custom family 11 | "link", # mboost::Binomial 12 | "type", # mboost::Binomial 13 | "offset" # handled by mlr3 14 | ) 15 | 16 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 17 | expect_paramtest(paramtest) 18 | }) 19 | 20 | test_that("paramtest classif.glmboost predict", { 21 | learner = lrn("classif.glmboost") 22 | fun_list = list(mboost:::predict.mboost) # nolint 23 | exclude = c( 24 | "object", 25 | "newdata", 26 | "aggregate", 27 | "which", 28 | "type" 29 | ) 30 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "predict") 31 | expect_paramtest(paramtest) 32 | }) 33 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_mboost_regr_gamboost.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest regr.gamboost train", { 2 | learner = lrn("regr.gamboost") 3 | fun_list = list(mboost::gamboost, mboost::boost_control) 4 | 5 | exclude = c( 6 | "formula", # handled via mlr3 7 | "data", # handled via mlr3 8 | "weights", # handled via mlr3 9 | "control", # handled to mboost::boost_control 10 | "center", # depreacated 11 | "custom.family", 12 | "nuirange", # Parameter belongs to the families GammaReg etc. 13 | "d", # Belongs to the Huber family 14 | "offset" # handled by mlr3 15 | ) 16 | 17 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 18 | expect_paramtest(paramtest) 19 | }) 20 | 21 | test_that("paramtest regr.gamboost predict", { 22 | learner = lrn("regr.gamboost") 23 | fun_list = list(mboost:::predict.mboost) # nolint 24 | 25 | exclude = c( 26 | "object", # mlr3 27 | "newdata", # mlr3 28 | "type", # mlr3 29 | "which", 30 | "aggregate" 31 | ) 32 | 33 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "predict") 34 | expect_paramtest(paramtest) 35 | }) 36 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_mboost_regr_glmboost.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest regr.glmboost train", { 2 | learner = lrn("regr.glmboost") 3 | fun_list = list(mboost:::glmboost.formula, mboost::boost_control) # nolint 4 | exclude = c( 5 | "formula", # handled via mlr3 6 | "data", # handled via mlr3 7 | "weights", # handled via mlr3 8 | "control", # handled to mboost::boost_control 9 | "center", # depreacated 10 | "custom.family", # possibility to pass custom family 11 | "nuirange", # GammaReg etc. 12 | "d", # Huber 13 | "offset" # handled by mlr3 14 | ) 15 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 16 | expect_paramtest(paramtest) 17 | }) 18 | 19 | 20 | test_that("paramtest regr.glmboost predict", { 21 | learner = lrn("regr.glmboost") 22 | fun = list(mboost:::predict.glmboost) # nolint 23 | exclude = c( 24 | "object", # handled by mlr3 25 | "newdata", # handled via mlr3 26 | "type", # handled via mlr3 27 | "which", 28 | "aggregate" 29 | ) 30 | paramtest = run_paramtest(learner, fun, exclude, tag = "predict") 31 | expect_paramtest(paramtest) 32 | }) 33 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_mboost_surv_blackboost.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest surv.blackboost train", { 2 | learner = lrn("surv.blackboost") 3 | fun_list = list(mboost::blackboost, mboost::boost_control, partykit::ctree_control) 4 | exclude = c( 5 | "formula", # handled via mlr3 6 | "data", # handled via mlr3 7 | "weights", # handled via mlr3 8 | "control", # handled to mboost::boost_control 9 | "tree_controls", # handled internally 10 | "custom.family", # pass a custom family (the rest is parametrized by characters) 11 | "pargs", # Args for families are implemented explicitly 12 | "maxvar", # not implemented by the author 13 | "numsurrogate", # for backward compatability with party 14 | "applyfun", # parallelization 15 | "cores", # parallelization 16 | "saveinfo", # parallelization 17 | "update", # parallelization 18 | "splitflavour", # feature may change 19 | # ths 20 | "nuirange", 21 | "maxpts", # mvtnorm::GenzBretz 22 | "abseps", # mvtnorm::GenzBretz 23 | "releps", # mvtnorm::GenzBretz 24 | "sigma", # mboost.:Cindex 25 | "ipcw", # mboost::Cindex 26 | "offset" # handled by mlr3 27 | ) 28 | 29 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 30 | expect_paramtest(paramtest) 31 | 32 | }) 33 | 34 | # no predict time parameters 35 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_mboost_surv_gamboost.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest surv.gamboost train", { 2 | learner = lrn("surv.gamboost") 3 | fun_list = list(mboost::gamboost, mboost::boost_control, mboost::CoxPH, mboost::Weibull, 4 | mboost::Loglog, mboost::Lognormal, mboost::Gehan, mboost::Cindex 5 | ) 6 | exclude = c( 7 | "formula", # handled via mlr3 8 | "data", # handled via mlr3 9 | "weights", # handled via mlr3 10 | "control", # handled to mboost::boost_control 11 | "custom.family", # extra param 12 | "offset" ## handled by mlr3 13 | ) 14 | 15 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 16 | expect_paramtest(paramtest) 17 | }) 18 | 19 | test_that("paramtest surv.gamboost predict", { 20 | learner = lrn("surv.gamboost") 21 | fun_list = list(mboost::predict.mboost) 22 | exclude = c( 23 | "object", 24 | "newdata", 25 | "type", 26 | "which", 27 | "aggregate" 28 | ) 29 | 30 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "predict") 31 | expect_paramtest(paramtest) 32 | }) 33 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_mboost_surv_glmboost.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest surv.glmboost train", { 2 | learner = lrn("surv.glmboost") 3 | fun_list = list(mboost:::glmboost.formula, mboost::boost_control) # nolint 4 | exclude = c( 5 | "formula", # handled via mlr3 6 | "data", # handled via mlr3 7 | "weights", # handled via mlr3 8 | "control", # handled to mboost::boost_control 9 | "custom.family", # Pass custom families as other families are parametrized as characters 10 | "nuirange", # e.g. mboost::Weibbull 11 | "sigma", # e.g. mboost::Cindex 12 | "ipcw", # e.g. mboost::Cindex 13 | "offset" # handled by mlr3 14 | ) 15 | 16 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 17 | expect_paramtest(paramtest) 18 | }) 19 | 20 | test_that("paramtest surv.glmboost predict", { 21 | learner = lrn("surv.glmboost") 22 | fun_list = list(mboost:::predict.glmboost) # nolint 23 | exclude = c( 24 | "object", 25 | "newdata", 26 | "type", 27 | "which", 28 | "aggregate" 29 | ) 30 | 31 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "predict") 32 | expect_paramtest(paramtest) 33 | }) 34 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_mboost_surv_mboost.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest surv.mboost train", { 2 | learner = lrn("surv.mboost") 3 | fun_list = list(mboost::boost_control, mboost::mboost, mboost::Weibull, mboost::Loglog, 4 | mboost::Lognormal, mboost::Gehan, mboost::Cindex) 5 | exclude = c( 6 | "center", # deprecated 7 | "formula", # mlr3 8 | "data", # mlr3 9 | "weights", # task 10 | "control", # mlr3 11 | "custom.family", # mlr3 12 | "offset" # handled by mlr3 13 | ) 14 | 15 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 16 | expect_paramtest(paramtest) 17 | }) 18 | 19 | test_that("paramtest surv.mboost predict", { 20 | learner = lrn("surv.mboost") 21 | fun_list = list() 22 | exclude = c( 23 | "family" # handled internally 24 | ) 25 | 26 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "predict") 27 | expect_paramtest(paramtest) 28 | }) 29 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_mda_regr_mars.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest regr.mars train", { 2 | learner = lrn("regr.mars") 3 | fun = mda::mars 4 | exclude = c( 5 | "x", # handled internally 6 | "y", # handled internally 7 | "w", # handled internally 8 | "wp", # ignored 9 | "prevfit" # ignored 10 | ) 11 | 12 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 13 | expect_paramtest(paramtest) 14 | }) 15 | 16 | test_that("paramtest regr.mars predict", { 17 | learner = lrn("regr.mars") 18 | fun = mda:::predict.mars # nolint 19 | exclude = c( 20 | "object", # handled internally 21 | "newdata" # handled internally 22 | ) 23 | 24 | paramtest = run_paramtest(learner, fun, exclude, tag = "predict") 25 | expect_paramtest(paramtest) 26 | }) 27 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_mgcv_regr_gam.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest regr.gam train", { 2 | learner = lrn("regr.gam") 3 | fun_list = list(mgcv::gam, mgcv::gam.control) 4 | exclude = c( 5 | "outerPIsteps", # weird errors in rcmdcheck (different result on devel and release) 6 | "data", # handled internally 7 | "weights", # handled internally 8 | "subset", # handled internally 9 | "na.action", # handled internally 10 | "control", # handled via "train" parameters 11 | "fit", # A model should be fitted 12 | "discrete", # experimental, should not be modified 13 | "keepData", # handled internally 14 | "offset" # handled by mlr3 15 | ) 16 | 17 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 18 | expect_paramtest(paramtest) 19 | }) 20 | 21 | test_that("paramtest regr.gam predict", { 22 | learner = lrn("regr.gam") 23 | fun = mgcv::predict.gam 24 | exclude = c( 25 | "na.action", # handled internally 26 | "object", # handled internally 27 | "newdata", # handled internally 28 | "type", # handled internally 29 | "newdata.guaranteed", # handled internally 30 | "se.fit", # handled internally 31 | "terms", # not relevant for predict type "se" or "response" 32 | "exclude", # not relevant for predict type "se" or "response" 33 | "iterms.type", # not relevant for predict type "se" or "response" 34 | "keepData" # handled internally 35 | ) 36 | 37 | paramtest = run_paramtest(learner, fun, exclude, tag = "predict") 38 | expect_paramtest(paramtest) 39 | }) 40 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_np_dens_mixed.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest dens.mixed train", { 2 | learner = lrn("dens.mixed") 3 | fun_list = list(np::npudens, np:::npudensbw.default) # nolint 4 | 5 | exclude = c( 6 | "dat", # handled by mlr3 7 | "scale.init.categorical.sample" # not implemented by the author 8 | ) 9 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 10 | expect_paramtest(paramtest) 11 | }) 12 | 13 | # No predict time parameters 14 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_partykit_classif_ctree.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = LearnerClassifCTree$new() 3 | expect_learner(learner) 4 | result = run_autotest(learner) 5 | expect_true(result, info = result$error) 6 | }) 7 | 8 | test_that("classif.ctree", { 9 | learner = lrn("classif.ctree") 10 | fun_list = list(partykit::ctree, partykit::ctree_control, partykit::predict.party, 11 | mvtnorm::GenzBretz 12 | ) 13 | exclude = c( 14 | "formula", # handled in mlr3 15 | "data", # handled in mlr3 16 | "subset", # handled in mlr3 17 | "weights", # handled in mlr3 18 | "na.action", # handled in mlr3 19 | "control", # handled in partykit::ctree_control 20 | "ytrafo", # handled in mlr3pipelines 21 | "converged", # not to be used by the user 22 | "perm", # used for variable importance (permuting the data) 23 | "newdata", # handled by mlr3 24 | "object", # handled by mlr3 25 | "pargs", # control parameters (GenzBretz()) are passed explicitly : 26 | "maxpts", # pargs param 27 | "releps", # pargs param 28 | "abseps", 29 | "offset" # is not directly supported by learner 30 | ) 31 | 32 | paramtest = run_paramtest(learner, fun_list, exclude) 33 | expect_paramtest(paramtest) 34 | }) 35 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_partykit_classif_mob.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest classif.mob train", { 2 | learner = lrn("classif.mob") 3 | fun_list = list(partykit::mob, partykit::mob_control) 4 | exclude = c( 5 | "formula", # handled in mlr3 6 | "data", # handled in mlr3 7 | "subset", # handled in mlr3 8 | "na.action", # handled in mlr3 9 | "weights", # handled in mlr3 10 | "control", # handled in partykit::mob_control 11 | "additional", # additional arguments passed to fitting function (instead of ...) 12 | "rhs" # used for construction of formula 13 | ) 14 | 15 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 16 | expect_paramtest(paramtest) 17 | }) 18 | 19 | test_that("paramtest classif.mob predict", { 20 | learner = lrn("classif.mob") 21 | fun_list = list(partykit:::predict.modelparty) # nolint 22 | exclude = c( 23 | "object", # handled by mlr3 24 | "newdata", # handled by mlr3 25 | "type", # implemented via predict_fun 26 | "predict_fun" # used for type 27 | ) 28 | 29 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "predict") 30 | expect_paramtest(paramtest) 31 | }) 32 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_partykit_regr_cforest.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest regr.cforest train", { 2 | learner = lrn("regr.cforest") 3 | fun_list = list(partykit::cforest, partykit::ctree_control) 4 | exclude = c( 5 | "formula", # handled in mlr3 6 | "data", # handled in mlr3 7 | "weights", # handled in mlr3 8 | "subset", # handled in mlr3 9 | "strata", # FIXME: handled in mlr3? 10 | "na.action", # handled in mlr3 11 | "control", # handled in partykit::ctree_control 12 | "ytrafo", # handled in mlr3pipelines 13 | "perturb", # handled separately 14 | "replace", # goes into perturb 15 | "fraction", # goes into perturb 16 | "mtryratio", # added as alternative to mtry 17 | # Parameters from varimp (needs a fix in partykit --> see learner) 18 | "nperm", 19 | "risk", 20 | "conditional", 21 | "threshold", 22 | "offset" # is not directly supported by learner 23 | ) 24 | 25 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 26 | expect_paramtest(paramtest) 27 | }) 28 | 29 | test_that("paramtest regr.cforest predict", { 30 | learner = lrn("regr.cforest") 31 | fun_list = list(partykit::predict.cforest) 32 | exclude = c( 33 | "object", # handled internally 34 | "newdata", # handled internally 35 | "type", # handled by mlr3 36 | "FUN" # summary statistics are handled by mlr3 with measures 37 | ) 38 | 39 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "predict") 40 | expect_paramtest(paramtest) 41 | }) 42 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_partykit_regr_ctree.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest regr.ctree train", { 2 | learner = lrn("regr.ctree") 3 | fun_list = list(partykit::ctree, partykit::ctree_control, mvtnorm::GenzBretz) 4 | exclude = c( 5 | "formula", # handled in mlr3 6 | "data", # handled in mlr3 7 | "subset", # handled in mlr3 8 | "weights", # handled in mlr3 9 | "na.action", # handled in mlr3 10 | "control", # handled in partykit::ctree_control 11 | "ytrafo", # handled in mlr3pipelines 12 | "converged", # not to be used by the user 13 | "pargs", # control parameters (GenzBretz()) are passed explicitly : 14 | "maxpts", # pargs param 15 | "releps", # pargs param 16 | "abseps", 17 | "offset" # is not directly supported by learner 18 | ) 19 | 20 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 21 | expect_paramtest(paramtest) 22 | }) 23 | 24 | test_that("regr.ctree", { 25 | learner = lrn("regr.ctree") 26 | fun_list = list(partykit::predict.party) 27 | exclude = c( 28 | "perm", # used for variable importance (permuting the data) 29 | "newdata", # handled by mlr3 30 | "object" # handled by mlr3 31 | ) 32 | 33 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "predict") 34 | expect_paramtest(paramtest) 35 | }) 36 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_partykit_regr_mob.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest regr.mob train", { 2 | learner = lrn("regr.mob") 3 | fun_list = list(partykit::mob, partykit::mob_control) 4 | exclude = c( 5 | "formula", # handled in mlr3 6 | "data", # handled in mlr3 7 | "subset", # handled in mlr3 8 | "na.action", # handled in mlr3 9 | "weights", # handled in mlr3 10 | "control", # handled in partykit::mob_control 11 | "additional", # additional arguments passed to fitting function (instead of ...) 12 | "rhs" # used for construction of formula 13 | ) 14 | 15 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 16 | expect_paramtest(paramtest) 17 | }) 18 | 19 | test_that("regr.mob", { 20 | learner = lrn("regr.mob") 21 | fun_list = list(partykit:::predict.modelparty) # nolint 22 | exclude = c( 23 | "object", # handled by mlr3 24 | "newdata", # handled by mlr3 25 | "type", # implemented via predict_fun 26 | "predict_fun" # used for type 27 | ) 28 | 29 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "predict") 30 | expect_paramtest(paramtest) 31 | }) 32 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_partykit_surv_ctree.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest surv.ctree train", { 2 | learner = lrn("surv.ctree") 3 | fun_list = list(partykit::ctree, partykit::ctree_control, partykit::predict.party, 4 | mvtnorm::GenzBretz) 5 | exclude = c( 6 | "formula", # handled in mlr3 7 | "data", # handled in mlr3 8 | "subset", # handled in mlr3 9 | "weights", # handled in mlr3 10 | "na.action", # handled in mlr3 11 | "control", # handled in partykit::ctree_control 12 | "ytrafo", # handled in mlr3pipelines 13 | "converged", # not to be used by the user 14 | "perm", # used for variable importance (permuting the data) 15 | "newdata", # handled by mlr3 16 | "object", # handled by mlr3 17 | "pargs", # control parameters (GenzBretz()) are passed explicitly : 18 | "maxpts", # pargs param 19 | "releps", # pargs param 20 | "abseps", 21 | "offset" # is not directly supported by learner 22 | ) 23 | 24 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 25 | expect_paramtest(paramtest) 26 | }) 27 | 28 | # 29 | # no predict time parameters 30 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_penalized_surv_penalized.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest surv.penalized train", { 2 | learner = lrn("surv.penalized") 3 | fun_list = list(penalized::penalized) 4 | exclude = c( 5 | "response", # coerced internally 6 | "penalized", # all variables assumed penalized unless passed to 'unpenalized' parameter 7 | "data", # coerced internally 8 | "model" # coerced internally 9 | ) 10 | 11 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 12 | expect_paramtest(paramtest) 13 | }) 14 | 15 | test_that("paramtest surv.penalized predict", { 16 | learner = lrn("surv.penalized") 17 | fun_list = list(penalized:::predict) # nolint 18 | exclude = c( 19 | "object", # passed internally 20 | "unpenalized" # see learner details 21 | ) 22 | 23 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "predict") 24 | expect_paramtest(paramtest) 25 | }) 26 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_pendensity_dens_pen.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest dens.pen train", { 2 | learner = lrn("dens.pen") 3 | fun_list = list(pendensity::pendensity) 4 | exclude = c( 5 | "form", # handled internally 6 | "data" # handled internally 7 | ) 8 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 9 | expect_paramtest(paramtest) 10 | }) 11 | 12 | # no predict time parameters 13 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_plugdensity_dens_plug.R: -------------------------------------------------------------------------------- 1 | test_that("dens.plug", { 2 | learner = lrn("dens.plug") 3 | fun = plugdensity::plugin.density 4 | exclude = c( 5 | "x", # handled internally 6 | "nout", # not required when `xout` used 7 | "xout" # handled in predict 8 | ) 9 | 10 | paramtest = run_paramtest(learner, fun, exclude) 11 | expect_paramtest(paramtest) 12 | }) 13 | 14 | # no predict time parameters 15 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_prioritylasso_classif_priority_lasso.R: -------------------------------------------------------------------------------- 1 | test_that("classif.priority_lasso train", { 2 | learner = lrn("classif.priority_lasso") 3 | fun = list(prioritylasso::prioritylasso, glmnet::cv.glmnet, glmnet::glmnet.control, glmnet::glmnet) 4 | 5 | exclude = c( 6 | "x", # handled internally 7 | "y", # handled internally, 8 | "X", # handled internally 9 | "Y", # handled internally, 10 | "weights", # handled internally, 11 | "family", # handled internally 12 | "itrace", # supported via param trace.it 13 | "factory", # only used in scripts, no effect within mlr3 14 | "scale.y", # only applies to regression 15 | "mcontrol" # this is tricky with the "missings" property as the learner still fails 16 | # unless parameters are set correctly 17 | ) 18 | 19 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 20 | expect_paramtest(paramtest) 21 | }) 22 | 23 | test_that("classif.priority_lasso predict", { 24 | learner = lrn("classif.priority_lasso") 25 | fun = list(prioritylasso:::predict.prioritylasso) # nolint 26 | exclude = c( 27 | "object", # handled internally 28 | "newdata", # handled internally 29 | "type", # handled internally 30 | "lambda.type", # predict.glmnet 31 | "predict.gamma", # is passed as gamma to predict.glmnet 32 | "s" # predict.glmnet 33 | ) 34 | 35 | paramtest = run_paramtest(learner, fun, exclude, tag = "predict") 36 | expect_paramtest(paramtest) 37 | }) 38 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_prioritylasso_regr_priority_lasso.R: -------------------------------------------------------------------------------- 1 | test_that("regr.priority_lasso train", { 2 | learner = lrn("regr.priority_lasso") 3 | fun = list(prioritylasso::prioritylasso, glmnet::cv.glmnet, glmnet::glmnet.control, glmnet::glmnet) 4 | exclude = c( 5 | "x", # handled internally 6 | "y", # handled internally, 7 | "X", # handled internally 8 | "Y", # handled internally, 9 | "weights", # handled internally, 10 | "family", # is "gaussian" for continuous data 11 | "type.measure", # is "mse" for continuous data 12 | "itrace", # supported via param trace.it 13 | "factory", 14 | "mcontrol" # this is tricky with the "missings" property as the learner still fails 15 | # unless parameters are set correctly 16 | ) 17 | 18 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 19 | expect_paramtest(paramtest) 20 | }) 21 | 22 | test_that("regr.priority_lasso predict", { 23 | learner = lrn("regr.priority_lasso", predict_type = "response") 24 | fun = list(prioritylasso:::predict.prioritylasso) # nolint 25 | exclude = c( 26 | "object", # handled internally 27 | "newdata", # handled internally 28 | "type", # handled internally 29 | "predict.gamma", # is passed as gamma to predict.glmnet 30 | "lambda.type", # predict.glmnet 31 | "s" # predict.glmnet 32 | ) 33 | 34 | paramtest = run_paramtest(learner, fun, exclude, tag = "predict") 35 | expect_paramtest(paramtest) 36 | }) 37 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_qgam_regr_mqgam.R: -------------------------------------------------------------------------------- 1 | test_that("regr.mqgam train", { 2 | learner = lrn("regr.mqgam") 3 | fun = qgam::mqgam 4 | exclude = c( 5 | "data", # handled internally 6 | "control", # handled internally 7 | "link", # handled internally via control 8 | "qu" # handled internally via self$quantiles 9 | ) 10 | 11 | # note that you can also pass a list of functions in case $.train calls more than one 12 | # function, e.g. for control arguments 13 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 14 | expect_paramtest(paramtest) 15 | }) 16 | 17 | test_that("regr.mqgam predict", { 18 | learner = lrn("regr.mqgam") 19 | fun = qgam::qdo 20 | exclude = c( 21 | "obj", # handled internally 22 | "fun", # handled internally 23 | "newdata", # handled internally 24 | "type", # handled internally 25 | "newdata.guaranteed", # handled internally 26 | "na.action", # handled internally 27 | "se.fit", # handled internally 28 | "terms", # not relevant for predict type "se" or "response" 29 | "exclude", # not relevant for predict type "se" or "response" 30 | "iterms.type", # not relevant for predict type "se" or "response" 31 | "qu" 32 | ) 33 | 34 | paramtest = run_paramtest(learner, fun, exclude, tag = "predict") 35 | expect_paramtest(paramtest) 36 | }) 37 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_qgam_regr_qgam.R: -------------------------------------------------------------------------------- 1 | test_that("regr.qgam train", { 2 | learner = lrn("regr.qgam") 3 | fun = qgam::qgam 4 | exclude = c( 5 | "data", # handled internally 6 | "control", # handled internally 7 | "link", # handled internally via control 8 | "qu" # handled internally via self$quantiles 9 | ) 10 | 11 | # note that you can also pass a list of functions in case $.train calls more than one 12 | # function, e.g. for control arguments 13 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 14 | expect_paramtest(paramtest) 15 | }) 16 | 17 | test_that("regr.qgam predict", { 18 | learner = lrn("regr.qgam") 19 | fun = mgcv::predict.gam 20 | exclude = c( 21 | "object", # handled internally 22 | "newdata", # handled internally 23 | "type", # handled internally 24 | "newdata.guaranteed", # handled internally 25 | "na.action", # handled internally 26 | "se.fit", # handled internally 27 | "terms", # not relevant for predict type "se" or "response" 28 | "exclude", # not relevant for predict type "se" or "response" 29 | "iterms.type", # not relevant for predict type "se" or "response" 30 | "qu" 31 | ) 32 | 33 | paramtest = run_paramtest(learner, fun, exclude, tag = "predict") 34 | expect_paramtest(paramtest) 35 | }) 36 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_randomForestSRC_classif_rfsrc.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest classif.rfsrc train", { 2 | learner = lrn("classif.rfsrc") 3 | fun_list = list(randomForestSRC::rfsrc) 4 | exclude = c( 5 | "formula", # handled internally 6 | "data", # handled internally 7 | "ytry", # for unsupervised forests only 8 | "yvar.wt", # not yet implemented 9 | "case.wt", # handled by task weights 10 | "mtry.ratio", 11 | "sampsize.ratio", 12 | "cores" # is set as option(rf.cores) 13 | ) 14 | 15 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 16 | expect_paramtest(paramtest) 17 | }) 18 | 19 | 20 | test_that("paramtest classif.rfsrc predict", { 21 | learner = lrn("classif.rfsrc") 22 | fun_list = list(randomForestSRC:::predict.rfsrc) # nolint 23 | exclude = c( 24 | "object", # handled internally 25 | "newdata", # handled internally 26 | "m.target", # all classes returned 27 | "cores", # is set as option(rf.cores) 28 | "perf.type" # scoring is done with measures 29 | ) 30 | 31 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "predict") 32 | expect_paramtest(paramtest) 33 | }) 34 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_randomForestSRC_regr_rfsrc.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest regr.rfsrc train", { 2 | learner = lrn("regr.rfsrc") 3 | fun_list = list(randomForestSRC::rfsrc) 4 | exclude = c( 5 | "formula", # handled internally 6 | "data", # handled internally 7 | "ytry", # for unsupervised forests only 8 | "yvar.wt", # not yet implemented 9 | "case.wt", # handled by task weights 10 | "cores", # set as option(rf.cores) 11 | "sampsize.ratio", # alternative to sampsize 12 | "mtry.ratio" # alternative to mtry 13 | ) 14 | 15 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 16 | expect_paramtest(paramtest) 17 | }) 18 | 19 | 20 | test_that("paramtest regr.rfsrc predict", { 21 | learner = lrn("regr.rfsrc") 22 | fun_list = list(randomForestSRC:::predict.rfsrc) # nolint 23 | exclude = c( 24 | "object", # handled internally 25 | "newdata", # handled internally 26 | "m.target", # for multivariate families only 27 | "cores", # set as option(rf.cores) 28 | "perf.type" # scoring is done with measures 29 | ) 30 | 31 | paramtest = run_paramtest(learner, fun_list, exclude, "predict") 32 | expect_paramtest(paramtest) 33 | }) 34 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_randomForestSRC_surv_rfsrc.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest surv.rfsrc train", { 2 | learner = lrn("surv.rfsrc") 3 | fun_list = list(randomForestSRC::rfsrc) 4 | exclude = c( 5 | "formula", # handled internally 6 | "data", # handled internally 7 | "ytry", # for unsupervised forests only 8 | "yvar.wt", # not yet implemented 9 | "case.wt", # handled by task weights 10 | "cores", # set as option(rf.cores) 11 | "sampsize.ratio", # alternative to sampsize 12 | "mtry.ratio" # alternative to mtry 13 | ) 14 | 15 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 16 | expect_paramtest(paramtest) 17 | }) 18 | 19 | 20 | test_that("paramtest surv.rfsrc predict", { 21 | learner = lrn("surv.rfsrc") 22 | fun_list = list(randomForestSRC:::predict.rfsrc) 23 | exclude = c( 24 | "object", # handled internally 25 | "newdata", # handled internally 26 | "m.target", # for multivariate families only 27 | "cores", # set as option(rf.cores) 28 | "estimator", # additionaly implemented by author 29 | "perf.type" # scoring is done with measures 30 | ) 31 | 32 | paramtest = run_paramtest(learner, fun_list, exclude, "predict") 33 | expect_paramtest(paramtest) 34 | }) 35 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_randomForest_classif_randomForest.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest classif.randomforest train", { 2 | learner = lrn("classif.randomForest") 3 | fun_list = list(randomForest:::randomForest.default) # nolint 4 | exclude = c( 5 | "x", # handled via mlr3 6 | "y", # handled via mlr3 7 | "xtest", # handled via mlr3 8 | "ytest", # handled via mlr3 9 | "corr.bias", # only regression 10 | "nPerm", # only regression 11 | "weights" # mlr3 12 | ) 13 | 14 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 15 | expect_paramtest(paramtest) 16 | }) 17 | 18 | test_that("paramtest classif.randomForest predict", { 19 | learner = lrn("classif.randomForest") 20 | fun_list = list(randomForest:::predict.randomForest) # nolint 21 | exclude = c( 22 | "object", # handled via mlr3 23 | "newdata", # handled via mlr3 24 | "type", # handled via mlr3 25 | "cutoff" # not implemented by author 26 | ) 27 | 28 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "predict") 29 | expect_paramtest(paramtest) 30 | }) 31 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_randomForest_regr_randomForest.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest regr.randomforest train", { 2 | learner = lrn("regr.randomForest") 3 | fun_list = list(randomForest:::randomForest.default) # nolint 4 | exclude = c( 5 | "x", # handled via mlr3 6 | "y", # handled via mlr3 7 | "xtest", # handled via mlr3 8 | "ytest", # handled via mlr3 9 | "corr.bias", # not implemented by author 10 | "nPerm", # not implemented by author 11 | "classwt", # classification only 12 | "cutoff", # classification only 13 | "weights" # mlr3 14 | ) 15 | 16 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 17 | expect_paramtest(paramtest) 18 | }) 19 | 20 | test_that("paramtest regr.randomForest predict", { 21 | learner = lrn("regr.randomForest") 22 | fun_list = list(randomForest:::predict.randomForest) # nolint 23 | exclude = c( 24 | "object", # handled via mlr3 25 | "newdata", # handled via mlr3 26 | "type", # handled via mlr3 27 | "cutoff", # classification only 28 | "norm.votes" # classification only 29 | ) 30 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "predict") 31 | expect_paramtest(paramtest) 32 | }) 33 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_randomPlantedForest_classif_rpf.R: -------------------------------------------------------------------------------- 1 | test_that("classif.rpf train", { 2 | learner = lrn("classif.rpf") 3 | fun = randomPlantedForest:::rpf.data.frame 4 | exclude = c( 5 | "x", "y", # handled internally 6 | # The following 2 are custom mlr3 parameters 7 | "max_interaction_ratio", 8 | "max_interaction_limit" 9 | ) 10 | 11 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 12 | expect_paramtest(paramtest) 13 | }) 14 | 15 | test_that("classif.rpf predict", { 16 | learner = lrn("classif.rpf") 17 | fun = randomPlantedForest:::predict.rpf # nolint 18 | exclude = c( 19 | "object", # handled internally 20 | "data", # handled internally 21 | "new_data", # handled internally 22 | "type" # handled internally via predict_type 23 | ) 24 | 25 | paramtest = run_paramtest(learner, fun, exclude, tag = "predict") 26 | expect_paramtest(paramtest) 27 | }) 28 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_randomPlantedForest_regr_rpf.R: -------------------------------------------------------------------------------- 1 | test_that("regr.rpf train", { 2 | learner = lrn("regr.rpf") 3 | fun = randomPlantedForest:::rpf.data.frame 4 | exclude = c( 5 | "x", "y", # handled internally 6 | "loss", # For regression, this parameter is redundant (only "L2" supported) 7 | # The following 2 parameters are control parameters for 8 | # classification only, and are ignored in the regression case 9 | "delta", 10 | "epsilon", 11 | # The following 2 are custom mlr3 parameters 12 | "max_interaction_ratio", 13 | "max_interaction_limit" 14 | ) 15 | 16 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 17 | expect_paramtest(paramtest) 18 | }) 19 | 20 | test_that("regr.rpf predict", { 21 | learner = lrn("regr.rpf") 22 | fun = randomPlantedForest:::predict.rpf # nolint 23 | exclude = c( 24 | "object", # handled internally 25 | "data", # handled internally 26 | "new_data", # handled internally 27 | "type" # handled internally by predict_type 28 | ) 29 | 30 | paramtest = run_paramtest(learner, fun, exclude, tag = "predict") 31 | expect_paramtest(paramtest) 32 | }) 33 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_rsm_regr_rsm.R: -------------------------------------------------------------------------------- 1 | test_that("regr.rsm train", { 2 | learner = lrn("regr.rsm") 3 | fun = rsm::rsm 4 | exclude = c( 5 | "object", # handled internally 6 | "data", # handled internally 7 | "modelfun", # custom parameter 8 | "formula" 9 | ) 10 | 11 | # note that you can also pass a list of functions in case $.train calls more than one 12 | # function, e.g. for control arguments 13 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 14 | expect_paramtest(paramtest) 15 | }) 16 | 17 | test_that("regr.rsm predict", { 18 | learner = lrn("regr.rsm") 19 | fun = predict 20 | exclude = c( 21 | "object", # handled internally 22 | "data", # handled internally 23 | "newdata" # handled internally 24 | 25 | ) 26 | 27 | paramtest = run_paramtest(learner, fun, exclude, tag = "predict") 28 | expect_paramtest(paramtest) 29 | }) 30 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_sm_dens_nonpar.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest dens.nonpar train", { 2 | learner = lrn("dens.nonpar") 3 | fun = sm::sm.density 4 | exclude = c( 5 | "x", # handled internally 6 | "weights", # handled by task 7 | "model", # only required for plotting 8 | # the following parameters are passed to sm.options 9 | "delta", 10 | "h.weights", 11 | "hmult", 12 | "method", 13 | "positive", 14 | "verbose" 15 | ) 16 | 17 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 18 | expect_paramtest(paramtest) 19 | }) 20 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_stats_regr_glm.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest regr.glm train", { 2 | learner = lrn("regr.glm") 3 | fun_list = list(stats::glm, stats::glm.control) 4 | exclude = c( 5 | "formula", # handled by mlr3 6 | "data", # handled by mlr3 7 | "weights", # handled by mlr3 8 | "subset", # handled by mlr3 9 | "method", # we always use glm() 10 | "control", # handled by glm.control 11 | "contrasts", # causes lots of troubles just when setting the defaul 12 | "link", # parameter passed to the family 13 | "offset" # handled by mlr3 14 | ) 15 | 16 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 17 | expect_paramtest(paramtest) 18 | }) 19 | 20 | test_that("paramtest regr.glm predict", { 21 | learner = lrn("regr.glm") 22 | fun = stats:::predict.glm # nolint 23 | exclude = c( 24 | "object", # handled via mlr3 25 | "newdata", # handled via mlr3 26 | "se.fit", # handled via mlr3 27 | "terms", # not implemented by author 28 | "use_pred_offset" # handled by mlr3 29 | ) 30 | 31 | paramtest = run_paramtest(learner, fun, exclude, tag = "predict") 32 | expect_paramtest(paramtest) 33 | }) 34 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_survival_surv_nelson.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = lrn("surv.nelson") 3 | expect_learner(learner) 4 | # sanity always 0.5 5 | result = run_autotest(learner, check_replicable = FALSE, exclude = "sanity") 6 | expect_true(result, info = result$error) 7 | }) 8 | 9 | test_that("surv.nelson", { 10 | learner = lrn("surv.nelson") 11 | fun = survival::survfit 12 | exclude = c("formula") # coerced internally 13 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 14 | expect_paramtest(paramtest) 15 | }) 16 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_survivalmodels_surv_akritas.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest surv.akritas train", { 2 | learner = lrn("surv.akritas") 3 | fun = survivalmodels::akritas 4 | exclude = c( 5 | "formula", # unused 6 | "data", # handled internally 7 | "reverse", # unused 8 | "time_variable", # handled internally 9 | "status_variable", # handled internally 10 | "x", # unused 11 | "y" # unused 12 | ) 13 | 14 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 15 | expect_paramtest(paramtest) 16 | }) 17 | 18 | test_that("paramtest surv.akritas predict", { 19 | learner = lrn("surv.akritas") 20 | fun = survivalmodels:::predict.akritas # nolint 21 | exclude = c( 22 | "object", # handled internally 23 | "newdata", # handled internally 24 | "times", # handled internally 25 | "type", # handled internally 26 | "distr6" # handled internally 27 | ) 28 | 29 | paramtest = run_paramtest(learner, fun, exclude, tag = "predict") 30 | expect_paramtest(paramtest) 31 | }) 32 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_survivalmodels_surv_coxtime.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest surv.coxtime train", { 2 | learner = lrn("surv.coxtime") 3 | fun_list = list(survivalmodels::coxtime, survivalmodels:::get_pycox_optim) # nolint 4 | exclude = c( 5 | "formula", # unused 6 | "data", # handled internally 7 | "reverse", # unused 8 | "time_variable", # handled internally 9 | "status_variable", # handled internally 10 | "x", # unused 11 | "y", # unused 12 | "net" # handled internally 13 | ) 14 | 15 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 16 | expect_paramtest(paramtest) 17 | }) 18 | 19 | test_that("paramtest surv.coxtime predict", { 20 | learner = lrn("surv.coxtime") 21 | fun = survivalmodels:::predict.pycox # nolint 22 | exclude = c( 23 | "object", # handled internally 24 | "newdata", # handled internally 25 | "type", # handled internally 26 | "distr6", # handled internally 27 | "interpolate", # unused 28 | "inter_scheme", # unused 29 | "sub" # unused 30 | ) 31 | 32 | paramtest = run_paramtest(learner, fun, exclude, tag = "predict") 33 | expect_paramtest(paramtest) 34 | }) 35 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_survivalmodels_surv_deephit.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest surv.deephit train", { 2 | learner = lrn("surv.deephit") 3 | fun_list = list(survivalmodels::deephit, survivalmodels:::get_pycox_optim) # nolint 4 | exclude = c( 5 | "formula", # unused 6 | "data", # handled internally 7 | "reverse", # unused 8 | "time_variable", # handled internally 9 | "status_variable", # handled internally 10 | "x", # unused 11 | "y", # unused 12 | "net" # handled internally 13 | ) 14 | 15 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 16 | expect_paramtest(paramtest) 17 | }) 18 | 19 | test_that("paramtest surv.deephit predict", { 20 | learner = lrn("surv.deephit") 21 | fun = survivalmodels:::predict.pycox # nolint 22 | exclude = c( 23 | "object", # handled internally 24 | "newdata", # handled internally 25 | "type", # handled internally 26 | "distr6" # handled internally 27 | ) 28 | 29 | paramtest = run_paramtest(learner, fun, exclude, tag = "predict") 30 | expect_paramtest(paramtest) 31 | }) 32 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_survivalmodels_surv_deepsurv.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest surv.deepsurv train", { 2 | learner = lrn("surv.deepsurv") 3 | fun_list = list(survivalmodels::deepsurv, survivalmodels:::get_pycox_optim) # nolint 4 | exclude = c( 5 | "formula", # unused 6 | "data", # handled internally 7 | "reverse", # unused 8 | "time_variable", # handled internally 9 | "status_variable", # handled internally 10 | "x", # unused 11 | "y", # unused 12 | "net" # handled internally 13 | ) 14 | 15 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 16 | expect_paramtest(paramtest) 17 | }) 18 | 19 | test_that("paramtest surv.deepsurv predict", { 20 | learner = lrn("surv.deepsurv") 21 | fun = survivalmodels:::predict.pycox # nolint 22 | exclude = c( 23 | "object", # handled internally 24 | "newdata", # handled internally 25 | "type", # handled internally 26 | "distr6", # handled internally 27 | "interpolate", # unused 28 | "inter_scheme", # unused 29 | "sub" # unused 30 | ) 31 | 32 | paramtest = run_paramtest(learner, fun, exclude, tag = "predict") 33 | expect_paramtest(paramtest) 34 | }) 35 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_survivalmodels_surv_dnnsurv.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest surv.dnnsurv train", { 2 | learner = lrn("surv.dnnsurv") 3 | fun_list = list(survivalmodels::dnnsurv, survivalmodels::get_keras_optimizer) 4 | 5 | exclude = c( 6 | "formula", # unused 7 | "data", # handled internally 8 | "reverse", # unused 9 | "time_variable", # handled internally 10 | "status_variable", # handled internally 11 | "x", # unused 12 | "y" # unused 13 | ) 14 | 15 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 16 | expect_paramtest(paramtest) 17 | }) 18 | 19 | test_that("paramtest surv.dnnsurv predict", { 20 | learner = lrn("surv.dnnsurv") 21 | fun = survivalmodels:::predict.dnnsurv # nolint 22 | exclude = c( 23 | "object", # handled internally 24 | "newdata", # handled internally 25 | "type", # handled internally 26 | "distr6" # handled internally 27 | ) 28 | 29 | paramtest = run_paramtest(learner, fun, exclude, tag = "predict") 30 | expect_paramtest(paramtest) 31 | }) 32 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_survivalmodels_surv_loghaz.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest surv.loghaz train", { 2 | learner = lrn("surv.loghaz") 3 | fun_list = list(survivalmodels::loghaz, survivalmodels::get_pycox_optim) 4 | exclude = c( 5 | "formula", # unused 6 | "data", # handled internally 7 | "reverse", # unused 8 | "time_variable", # handled internally 9 | "status_variable", # handled internally 10 | "x", # unused 11 | "y", # unused 12 | "net" # handled internally 13 | ) 14 | 15 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 16 | expect_paramtest(paramtest) 17 | }) 18 | 19 | test_that("paramtest surv.loghaz predict", { 20 | learner = lrn("surv.loghaz") 21 | fun = survivalmodels:::predict.pycox # nolint 22 | exclude = c( 23 | "object", # handled internally 24 | "newdata", # handled internally 25 | "type", # handled internally 26 | "distr6" # handled internally 27 | ) 28 | 29 | paramtest = run_paramtest(learner, fun, exclude, tag = "predict") 30 | expect_paramtest(paramtest) 31 | }) 32 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_survivalmodels_surv_pchazard.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest surv.pchazard train", { 2 | learner = lrn("surv.pchazard") 3 | fun_list = list(survivalmodels::pchazard, survivalmodels:::get_pycox_optim) # nolint 4 | exclude = c( 5 | "formula", # unused 6 | "data", # handled internally 7 | "reverse", # unused 8 | "time_variable", # handled internally 9 | "status_variable", # handled internally 10 | "x", # unused 11 | "y", # unused 12 | "net" # handled internally 13 | ) 14 | 15 | paramtest = run_paramtest(learner, fun_list, exclude, tag = "train") 16 | expect_paramtest(paramtest) 17 | }) 18 | 19 | test_that("paramtest surv.pchazard predict", { 20 | learner = lrn("surv.pchazard") 21 | fun = survivalmodels:::predict.pycox # nolint 22 | exclude = c( 23 | "object", # handled internally 24 | "newdata", # handled internally 25 | "type", # handled internally 26 | "distr6", # handled internally 27 | "inter_scheme" # deephit and loghaz only 28 | ) 29 | 30 | paramtest = run_paramtest(learner, fun, exclude, tag = "predict") 31 | expect_paramtest(paramtest) 32 | }) 33 | -------------------------------------------------------------------------------- /tests/testthat/test_paramtest_survivalsvm_surv_svm.R: -------------------------------------------------------------------------------- 1 | test_that("paramtest surv.svm_train", { 2 | learner = lrn("surv.svm") 3 | fun = survivalsvm::survivalsvm 4 | exclude = c( 5 | "formula", # coerced internally 6 | "data", # coerced internally by task 7 | "subset", # coerced internally by task 8 | "time.variable.name", # unused alternative formulation to formula 9 | "status.variable.name", # unused alternative formulation to formula 10 | "gamma.mu", "gamma", "mu" # we split the original parameter to two new ones 11 | ) 12 | 13 | paramtest = run_paramtest(learner, fun, exclude, tag = "train") 14 | expect_paramtest(paramtest) 15 | }) 16 | 17 | test_that("paramtest surv.svm predict", { 18 | learner = lrn("surv.svm") 19 | fun = survivalsvm:::predict.survivalsvm # nolint 20 | exclude = c( 21 | "object", # passed internally 22 | "newdata", # coerced internally by task 23 | "subset" # coerced internally by task 24 | ) 25 | 26 | paramtest = run_paramtest(learner, fun, exclude, tag = "predict") 27 | expect_paramtest(paramtest) 28 | }) 29 | -------------------------------------------------------------------------------- /tests/testthat/test_partykit_classif_cforest.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = LearnerClassifCForest$new() 3 | learner$param_set$values = list(ntree = 30L) 4 | expect_learner(learner) 5 | result = with_seed(1, run_autotest(learner)) 6 | expect_true(result, info = result$error) 7 | }) 8 | 9 | test_that("parameter setting works", { 10 | learner = LearnerClassifCForest$new() 11 | learner$param_set$values$ntree = 3 12 | learner$param_set$values$replace = TRUE 13 | learner$param_set$values$fraction = 0.7 14 | learner$param_set$values$teststat = "maximum" 15 | learner$param_set$values$OOB = TRUE 16 | task = tsk("iris") 17 | learner$train(task) 18 | expect_equal(length(learner$model$nodes), 3L) 19 | expect_equal(learner$model$info$control$teststat, "maximum") 20 | }) 21 | -------------------------------------------------------------------------------- /tests/testthat/test_partykit_classif_ctree.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = LearnerClassifCTree$new() 3 | expect_learner(learner) 4 | result = run_autotest(learner) 5 | expect_true(result, info = result$error) 6 | }) 7 | -------------------------------------------------------------------------------- /tests/testthat/test_partykit_classif_mob.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | # use a senseless logit model and partition with respect to all features 3 | logit_ = function(y, x, start = NULL, weights = NULL, offset = NULL, ...) { 4 | glm(y ~ 1, family = binomial, start = start, ...) 5 | } 6 | learner = LearnerClassifMob$new() 7 | learner$param_set$values$rhs = "." 8 | learner$param_set$values$fit = logit_ 9 | learner$param_set$values$additional = list(maxit = 100) 10 | learner$feature_types = c("logical", "integer", "numeric", "factor", "ordered") 11 | learner$properties = c("twoclass", "weights") 12 | 13 | predict_fun = function(object, newdata, task, .type) { 14 | p = unname(predict(object, newdata = newdata, type = "response")) 15 | levs = task$levels(task$target_names)[[1L]] 16 | 17 | if (.type == "response") { 18 | ifelse(p < 0.5, levs[1L], levs[2L]) 19 | } else { 20 | prob_vector_to_matrix(p, levs) 21 | } 22 | } 23 | learner$param_set$values$predict_fun = predict_fun 24 | expect_learner(learner) 25 | result = run_autotest(learner, exclude = "sanity") 26 | expect_true(result, info = result$error) 27 | }) 28 | -------------------------------------------------------------------------------- /tests/testthat/test_partykit_regr_cforest.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = LearnerRegrCForest$new() 3 | learner$param_set$values = list(ntree = 30L) 4 | expect_learner(learner) 5 | result = run_autotest(learner) 6 | expect_true(result, info = result$error) 7 | }) 8 | 9 | test_that("parameter setting works", { 10 | learner = LearnerRegrCForest$new() 11 | learner$param_set$values$ntree = 3 12 | learner$param_set$values$replace = TRUE 13 | learner$param_set$values$fraction = 0.7 14 | learner$param_set$values$teststat = "maximum" 15 | learner$param_set$values$OOB = TRUE 16 | task = tsk("mtcars") 17 | learner$train(task) 18 | expect_equal(length(learner$model$nodes), 3L) 19 | expect_equal(learner$model$info$control$teststat, "maximum") 20 | }) 21 | -------------------------------------------------------------------------------- /tests/testthat/test_partykit_regr_ctree.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = LearnerRegrCTree$new() 3 | expect_learner(learner) 4 | result = run_autotest(learner) 5 | expect_true(result, info = result$error) 6 | }) 7 | -------------------------------------------------------------------------------- /tests/testthat/test_partykit_regr_mob.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | set.seed(1) 3 | # use a senseless linear model and partition with respect to all features 4 | lm_ = function(y, x, start = NULL, weights = NULL, offset = NULL, ...) { 5 | lm(y ~ 1, ...) 6 | } 7 | learner = LearnerRegrMob$new() 8 | learner$param_set$values$rhs = "." 9 | learner$param_set$values$fit = lm_ 10 | learner$feature_types = c("logical", "integer", "numeric", "factor", "ordered") 11 | 12 | predict_fun = function(object, newdata, task, .type) { 13 | preds = predict(object, newdata = newdata, type = "response", se.fit = TRUE) 14 | cbind(preds$fit, preds$se.fit) 15 | } 16 | learner$param_set$values$predict_fun = predict_fun 17 | expect_learner(learner) 18 | result = run_autotest(learner, exclude = "sanity") 19 | expect_true(result, info = result$error) 20 | }) 21 | -------------------------------------------------------------------------------- /tests/testthat/test_partykit_surv_cforest.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = lrn("surv.cforest", ntree = 5) 3 | expect_learner(learner) 4 | result = run_autotest(learner, check_replicable = FALSE, exclude = "sanity") 5 | expect_true(result, info = result$error) 6 | }) 7 | 8 | test_that("correct prediction types", { 9 | with_seed(42, { 10 | task = tsk("rats")$filter(sample(1:300, 50)) 11 | part = partition(task, ratio = 0.9) 12 | train_rows = part$train 13 | test_rows = part$test 14 | unique_times = task$unique_times(train_rows) 15 | 16 | learner = lrn("surv.cforest", ntree = 5) 17 | p = learner$train(task, part$train)$predict(task, test_rows) 18 | expect_matrix(p$data$distr, nrows = length(test_rows), 19 | max.cols = length(unique_times)) 20 | expect_numeric(p$crank, len = length(test_rows)) 21 | }) 22 | }) 23 | -------------------------------------------------------------------------------- /tests/testthat/test_partykit_surv_ctree.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | with_seed(42, { 3 | learner = lrn("surv.ctree") 4 | expect_learner(learner) 5 | result = run_autotest(learner, check_replicable = FALSE) 6 | expect_true(result, info = result$error) 7 | }) 8 | }) 9 | 10 | test_that("correct prediction types", { 11 | with_seed(42, { 12 | task = tsk("rats")$filter(sample(1:300, 50)) 13 | part = partition(task, ratio = 0.9) 14 | train_rows = part$train 15 | test_rows = part$test 16 | unique_times = task$unique_times(train_rows) 17 | 18 | learner = lrn("surv.ctree") 19 | p = learner$train(task, train_rows)$predict(task, test_rows) 20 | expect_matrix(p$data$distr, nrows = length(test_rows), 21 | max.cols = length(unique_times)) 22 | expect_numeric(p$crank, len = length(test_rows)) 23 | }) 24 | }) 25 | -------------------------------------------------------------------------------- /tests/testthat/test_penalized_surv_penalized.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = lrn("surv.penalized") 3 | expect_learner(learner) 4 | result = run_autotest(learner, check_replicable = FALSE) 5 | expect_true(result, info = result$error) 6 | }) 7 | 8 | test_that("unpenalized", { 9 | task = tsk("rats") 10 | learner = lrn("surv.penalized", unpenalized = "litter") 11 | learner$train(task) 12 | expect_equal(names(learner$model$model@penalized), c("rx", "sexm")) 13 | expect_equal(names(learner$model$model@unpenalized), c("litter")) 14 | expect_prediction_surv(learner$predict(task)) 15 | # unpenalized features have to be in present 16 | learner = lrn("surv.penalized", unpenalized = "li") 17 | expect_error(learner$train(task), "values not present in task") 18 | }) 19 | 20 | test_that("can't get selected features on task with factors", { 21 | task = tsk("lung") 22 | learner = lrn("surv.penalized") 23 | learner$train(task) 24 | expect_class(learner$model$model, "penfit") 25 | expect_error(learner$selected_features()) 26 | }) 27 | -------------------------------------------------------------------------------- /tests/testthat/test_pendensity_dens_pen.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = lrn("dens.pen") 3 | expect_learner(learner) 4 | result = run_autotest(learner) 5 | expect_true(result, info = result$error) 6 | }) 7 | -------------------------------------------------------------------------------- /tests/testthat/test_plugdensity_dens_plug.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | set.seed(1) 3 | learner = LearnerDensPlugin$new() 4 | expect_learner(learner) 5 | # mrl3proba's generate_task does not respect feature types 6 | result = run_autotest(learner, exclude = "integer") 7 | expect_true(result, info = result$error) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test_prioritylasso_classif_priority_lasso.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | # These shenanigans are necessary because we have to dynanically set the blocks, depending on the task 3 | set.seed(1) 4 | # blocks gets changed later anyway but is required 5 | learner = lrn("classif.priority_lasso", type.measure = "class", blocks = "PLACEHOLDER") 6 | on.exit({ 7 | assignInNamespace(".__LearnerClassifPriorityLasso__.train", train_old, ns = "mlr3extralearners") 8 | }, add = TRUE) 9 | train_old = mlr3extralearners:::.__LearnerClassifPriorityLasso__.train # nolint 10 | 11 | src = as.list(body(train_old)) 12 | new_lines = list( 13 | quote(s <- seq_along(task$feature_names)), 14 | quote(pars$blocks <- set_names(list(s), "bp1")) 15 | ) 16 | src = c(src[1:2], new_lines, src[3:length(src)]) 17 | new_body = as.call(src) 18 | train = train_old 19 | body(train) = new_body 20 | assignInNamespace(".__LearnerClassifPriorityLasso__.train", train, ns = "mlr3extralearners") 21 | 22 | result = run_autotest(learner, exclude = "feat_single") 23 | expect_true(result, info = result$error) 24 | }) 25 | -------------------------------------------------------------------------------- /tests/testthat/test_prioritylasso_regr_priority_lasso.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | # These shenanigans are necessary because we have to dynanically set the blocks, depending on the 3 | set.seed(1) 4 | learner = lrn("regr.priority_lasso", blocks = "PLACEHOLDER") 5 | on.exit({ 6 | assignInNamespace(".__LearnerRegrPriorityLasso__.train", train_old, ns = "mlr3extralearners") 7 | }, add = TRUE) 8 | train_old = mlr3extralearners:::.__LearnerRegrPriorityLasso__.train # nolint 9 | 10 | src = as.list(body(train_old)) 11 | new_lines = list( 12 | quote(s <- seq_along(task$feature_names)), 13 | quote(pars$blocks <- set_names(list(s), "bp1")) 14 | ) 15 | src = c(src[1:2], new_lines, src[3:length(src)]) 16 | new_body = as.call(src) 17 | train = train_old 18 | body(train) = new_body 19 | assignInNamespace(".__LearnerRegrPriorityLasso__.train", train, ns = "mlr3extralearners") 20 | 21 | result = run_autotest(learner, exclude = "feat_single") 22 | expect_true(result, info = result$error) 23 | }) 24 | -------------------------------------------------------------------------------- /tests/testthat/test_prioritylasso_surv_priority_lasso.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | # These shenanigans are necessary because we have to dynanically set the blocks, depending on the task 3 | set.seed(1) 4 | # blocks gets changed later anyway but is required 5 | learner = lrn("surv.priority_lasso", blocks = "PLACEHOLDER") 6 | on.exit({ 7 | assignInNamespace(".__LearnerSurvPriorityLasso__.train", train_old, ns = "mlr3extralearners") 8 | }, add = TRUE) 9 | train_old = mlr3extralearners:::.__LearnerSurvPriorityLasso__.train # nolint 10 | 11 | src = as.list(body(train_old)) 12 | new_lines = list( 13 | quote(s <- seq_along(task$feature_names)), 14 | quote(pars$blocks <- set_names(list(s), "bp1")) 15 | ) 16 | src = c(src[1:2], new_lines, src[3:length(src)]) 17 | new_body = as.call(src) 18 | train = train_old 19 | body(train) = new_body 20 | assignInNamespace(".__LearnerSurvPriorityLasso__.train", train, ns = "mlr3extralearners") 21 | 22 | result = run_autotest(learner, exclude = "feat_single") 23 | expect_true(result, info = result$error) 24 | }) 25 | -------------------------------------------------------------------------------- /tests/testthat/test_qgam_regr_mqgam.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = lrn("regr.mqgam") 3 | expect_learner(learner, check_man = FALSE) 4 | result = run_autotest(learner, exclude = "utf8_feature_names") 5 | expect_true(result, info = result$error) 6 | }) 7 | -------------------------------------------------------------------------------- /tests/testthat/test_qgam_regr_qgam.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = lrn("regr.qgam") 3 | expect_learner(learner) 4 | result = run_autotest(learner, exclude = "utf8_feature_names") 5 | expect_true(result, info = result$error) 6 | }) 7 | -------------------------------------------------------------------------------- /tests/testthat/test_randomForestSRC_classif_imbalanced_rfsrc.R: -------------------------------------------------------------------------------- 1 | test_that("importance/selected", { 2 | set.seed(1) 3 | task = tsk("breast_cancer") 4 | learner = lrn("classif.imbalanced_rfsrc") 5 | learner$train(task) 6 | expect_error(learner$importance(), "Set 'importance'") 7 | expect_error(learner$selected_features(), "Set 'var.used'") 8 | }) 9 | 10 | test_that("autotest", { 11 | learner = lrn("classif.imbalanced_rfsrc") 12 | learner$param_set$values = list( 13 | importance = "random", na.action = "na.impute", 14 | do.trace = TRUE) 15 | expect_learner(learner) 16 | set.seed(1) 17 | result = run_autotest(learner, exclude = "uf8_feature_names") 18 | expect_true(result, info = result$error) 19 | }) 20 | 21 | test_that("convert_ratio", { 22 | task = tsk("sonar") 23 | learner = lrn("classif.imbalanced_rfsrc", ntree = 5, mtry.ratio = .5) 24 | expect_equal(learner$train(task)$model$mtry, 30) 25 | 26 | learner$param_set$values$mtry.ratio = 0 27 | expect_equal(learner$train(task)$model$mtry, 1) 28 | 29 | learner$param_set$values$mtry.ratio = 1 30 | expect_equal(learner$train(task)$model$mtry, 60) 31 | 32 | learner$param_set$values$mtry = 10 33 | expect_error(learner$train(task), "exclusive") 34 | 35 | learner$param_set$values$mtry.ratio = NULL 36 | expect_equal(learner$train(task)$model$mtry, 10) 37 | }) 38 | -------------------------------------------------------------------------------- /tests/testthat/test_randomForestSRC_classif_rfsrc.R: -------------------------------------------------------------------------------- 1 | test_that("importance/selected", { 2 | set.seed(1) 3 | task = tsk("iris") 4 | learner = lrn("classif.rfsrc") 5 | learner$train(task) 6 | expect_error(learner$importance(), "Set 'importance'") 7 | expect_error(learner$selected_features(), "Set 'var.used'") 8 | }) 9 | 10 | test_that("autotest", { 11 | learner = lrn("classif.rfsrc") 12 | learner$param_set$values = list( 13 | importance = "random", na.action = "na.impute", 14 | do.trace = TRUE) 15 | expect_learner(learner) 16 | set.seed(1) 17 | result = run_autotest(learner, exclude = "uf8_feature_names") 18 | expect_true(result, info = result$error) 19 | }) 20 | 21 | test_that("convert_ratio", { 22 | task = tsk("sonar") 23 | learner = lrn("classif.rfsrc", ntree = 5, mtry.ratio = .5) 24 | expect_equal(learner$train(task)$model$mtry, 30) 25 | 26 | learner$param_set$values$mtry.ratio = 0 27 | expect_equal(learner$train(task)$model$mtry, 1) 28 | 29 | learner$param_set$values$mtry.ratio = 1 30 | expect_equal(learner$train(task)$model$mtry, 60) 31 | 32 | learner$param_set$values$mtry = 10 33 | expect_error(learner$train(task), "exclusive") 34 | 35 | learner$param_set$values$mtry.ratio = NULL 36 | expect_equal(learner$train(task)$model$mtry, 10) 37 | }) 38 | -------------------------------------------------------------------------------- /tests/testthat/test_randomForestSRC_regr_rfsrc.R: -------------------------------------------------------------------------------- 1 | test_that("importance/selected", { 2 | set.seed(1) 3 | task = tsk("boston_housing") 4 | learner = lrn("regr.rfsrc") 5 | learner$train(task) 6 | expect_error(learner$importance(), "Set 'importance'") 7 | expect_error(learner$selected_features(), "Set 'var.used'") 8 | }) 9 | 10 | test_that("autotest", { 11 | learner = lrn("regr.rfsrc") 12 | learner$param_set$values = list( 13 | importance = "random", na.action = "na.impute", 14 | do.trace = TRUE) 15 | expect_learner(learner) 16 | set.seed(1) 17 | result = run_autotest(learner, exclude = "single") 18 | expect_true(result, info = result$error) 19 | }) 20 | -------------------------------------------------------------------------------- /tests/testthat/test_randomForestSRC_surv_rfsrc.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = lrn("surv.rfsrc") 3 | learner$param_set$values = insert_named( 4 | learner$param_set$values, 5 | list(importance = "random", na.action = "na.impute")) 6 | expect_learner(learner) 7 | set.seed(1) 8 | result = run_autotest(learner, check_replicable = FALSE, N = 100) 9 | expect_true(result, info = result$error) 10 | }) 11 | 12 | test_that("importance/selected", { 13 | set.seed(1) 14 | task = tsk("rats") 15 | learn = LearnerSurvRandomForestSRC$new() 16 | learn$param_set$values = list(estimator = "kaplan") 17 | learn$train(task) 18 | expect_error(learn$importance(), "Set 'importance'") 19 | expect_error(learn$selected_features(), "Set 'var.used'") 20 | learn$param_set$values = list(estimator = "nelson", var.used = "all.trees", importance = "random") 21 | learn$train(task) 22 | expect_silent(learn$selected_features()) 23 | expect_silent(learn$importance()) 24 | expect_silent(learn$oob_error()) 25 | }) 26 | -------------------------------------------------------------------------------- /tests/testthat/test_randomForest_classif_randomForest.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = LearnerClassifRandomForest$new() 3 | learner$param_set$values = list(importance = "gini") 4 | expect_learner(learner) 5 | result = run_autotest(learner, exclude = "utf8_feature_names") 6 | expect_true(result, info = result$error) 7 | }) 8 | -------------------------------------------------------------------------------- /tests/testthat/test_randomForest_regr_randomForest.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = LearnerRegrRandomForest$new() 3 | learner$param_set$values = list("importance" = "mse") 4 | expect_learner(learner) 5 | result = run_autotest(learner, exclude = "utf8_feature_names") 6 | expect_true(result, info = result$error) 7 | }) 8 | -------------------------------------------------------------------------------- /tests/testthat/test_randomPlantedForest_classif_rpf.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = lrn("classif.rpf") 3 | expect_learner(learner) 4 | result = run_autotest(learner) 5 | expect_true(result, info = result$error) 6 | }) 7 | -------------------------------------------------------------------------------- /tests/testthat/test_randomPlantedForest_regr_rpf.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = lrn("regr.rpf") 3 | expect_learner(learner) 4 | result = run_autotest(learner) 5 | expect_true(result, info = result$error) 6 | }) 7 | -------------------------------------------------------------------------------- /tests/testthat/test_ranger_surv_ranger.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | with_seed(1, { 3 | learner = mlr_learners$get("surv.ranger") 4 | expect_learner(learner) 5 | learner$param_set$values = list(importance = "impurity") 6 | result = run_autotest(learner, check_replicable = FALSE) 7 | expect_true(result, info = result$error) 8 | }) 9 | }) 10 | 11 | test_that("importance", { 12 | learner = mlr_learners$get("surv.ranger") 13 | expect_error(learner$importance(), "No model stored") 14 | expect_error(learner$train(tsk("rats"))$importance(), "No importance stored") 15 | }) 16 | 17 | test_that("mtry.ratio", { 18 | task = mlr3::tsk("rats") 19 | learner = mlr3::lrn("surv.ranger", mtry.ratio = 0.5) 20 | 21 | res = convert_ratio(learner$param_set$values, "mtry", "mtry.ratio", length(task$feature_names)) 22 | expect_equal( 23 | res$mtry, 24 | 2 25 | ) 26 | expect_null(res$mtry.ratio) 27 | 28 | learner$train(task) 29 | expect_equal( 30 | learner$model$mtry, 31 | 2 32 | ) 33 | }) 34 | -------------------------------------------------------------------------------- /tests/testthat/test_rsm_regr_rsm.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = lrn("regr.rsm") 3 | expect_learner(learner) 4 | # note that you can skip tests using the exclude argument 5 | result = run_autotest(learner, exclude = "utf8_feature_names") 6 | expect_true(result, info = result$error) 7 | }) 8 | -------------------------------------------------------------------------------- /tests/testthat/test_rweka_helper.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("rweka_helper train", { 4 | task = tsk("breast_cancer") 5 | weka_learner = RWeka::DecisionStump 6 | learner = lrn("classif.decision_stump") 7 | pars = learner$param_set$get_values(tags = "train") 8 | model = rweka_train(task$data(), task$formula(), pars, weka_learner) 9 | expect_class(model, "Weka_classifier") 10 | }) 11 | 12 | test_that("rweka_helper predict", { 13 | task = tsk("breast_cancer") 14 | weka_learner = RWeka::DecisionStump 15 | learner = lrn("classif.decision_stump") 16 | pars = learner$param_set$get_values(tags = "predict") 17 | model = rweka_train(task$data(), task$formula(), pars, weka_learner) 18 | for (predict_type in learner$predict_types) { 19 | prediction = rweka_predict(task$data(), pars, predict_type, model) 20 | expect_list(prediction) 21 | expect_equal(names(prediction), predict_type) 22 | } 23 | }) 24 | -------------------------------------------------------------------------------- /tests/testthat/test_sm_dens_nonpar.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = LearnerDensNonparametric$new() 3 | expect_learner(learner) 4 | result = run_autotest(learner, check_replicable = FALSE) 5 | expect_true(result, info = result$error) 6 | }) 7 | -------------------------------------------------------------------------------- /tests/testthat/test_survival_surv_nelson.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = lrn("surv.nelson") 3 | expect_learner(learner) 4 | # sanity always 0.5 5 | result = run_autotest(learner, check_replicable = FALSE, exclude = "sanity") 6 | expect_true(result, info = result$error) 7 | }) 8 | -------------------------------------------------------------------------------- /tests/testthat/test_survivalmodels_surv_akritas.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = LearnerSurvAkritas$new() 3 | expect_learner(learner) 4 | result = run_autotest(learner, check_replicable = FALSE, exclude = "sanity") 5 | # sanity test disabled, because akritas is similar to the Kaplan-Meier in that dependent on parameter it always predicts 0.5 6 | # whereas the sanity check requires >= 0.6 7 | expect_true(result, info = result$error) 8 | }) 9 | 10 | test_that("time points for prediction", { 11 | task = tsk("lung") 12 | learner = lrn("surv.akritas") 13 | p = learner$train(task)$predict(task) 14 | times = as.integer(colnames(p$data$distr)) 15 | expect_equal(times, task$unique_times()) # unique train time points are used 16 | 17 | # use many more time points than the ones in the train set 18 | learner$param_set$set_values(.values = list(ntime = 9999)) 19 | p = learner$train(task)$predict(task) 20 | times = as.integer(colnames(p$data$distr)) 21 | expect_equal(times, task$unique_times()) # all unique train time points are still used 22 | 23 | learner$param_set$set_values(.values = list(ntime = 50)) 24 | p = learner$train(task)$predict(task) 25 | times = as.integer(colnames(p$data$distr)) 26 | # min and max times are retained after coersion 27 | expect_equal(min(times), min(task$unique_times())) 28 | expect_equal(max(times), max(task$unique_times())) 29 | expect_equal(length(times), 50) 30 | }) 31 | -------------------------------------------------------------------------------- /tests/testthat/test_survivalmodels_surv_coxtime.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | if (!reticulate::py_module_available("torch") || !reticulate::py_module_available("pycox") || 4 | !reticulate::py_module_available("numpy")) { 5 | skip("One of torch, numpy, pycox not available for testing.") 6 | } 7 | 8 | np = reticulate::import("numpy") 9 | torch = reticulate::import("torch") 10 | set.seed(1) 11 | np$random$seed(1L) 12 | torch$manual_seed(1L) 13 | 14 | test_that("autotest", { 15 | learner = lrn("surv.coxtime") 16 | expect_learner(learner) 17 | # single test fails randomly I think this depends on the python version 18 | result = run_autotest(learner, check_replicable = FALSE, exclude = "sanity || feat_single") 19 | expect_true(result, info = result$error) 20 | }) 21 | -------------------------------------------------------------------------------- /tests/testthat/test_survivalmodels_surv_deephit.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | if (!reticulate::py_module_available("torch") || !reticulate::py_module_available("pycox") || 4 | !reticulate::py_module_available("numpy")) { 5 | skip("One of torch, numpy, pycox not available for testing.") 6 | } 7 | 8 | np = reticulate::import("numpy") 9 | torch = reticulate::import("torch") 10 | set.seed(1) 11 | np$random$seed(1L) 12 | torch$manual_seed(1L) 13 | 14 | test_that("autotest", { 15 | learner = lrn("surv.deephit") 16 | expect_learner(learner) 17 | result = run_autotest(learner, check_replicable = FALSE, exclude = "sanity") 18 | expect_true(result, info = result$error) 19 | }) 20 | -------------------------------------------------------------------------------- /tests/testthat/test_survivalmodels_surv_deepsurv.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | if (!reticulate::py_module_available("torch") || !reticulate::py_module_available("pycox") || 4 | !reticulate::py_module_available("numpy")) { 5 | skip("One of torch, numpy, pycox not available for testing.") 6 | } 7 | 8 | np = reticulate::import("numpy") 9 | torch = reticulate::import("torch") 10 | set.seed(1) 11 | np$random$seed(1L) 12 | torch$manual_seed(1L) 13 | 14 | test_that("autotest", { 15 | learner = lrn("surv.deepsurv") 16 | expect_learner(learner) 17 | result = run_autotest(learner, check_replicable = FALSE, exclude = "sanity") 18 | expect_true(result, info = result$error) 19 | }) 20 | -------------------------------------------------------------------------------- /tests/testthat/test_survivalmodels_surv_dnnsurv.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | test_that("autotest", { 4 | set.seed(10) 5 | learner = lrn("surv.dnnsurv", cuts = 5) 6 | expect_learner(learner) 7 | result = run_autotest(learner, check_replicable = FALSE, exclude = "sanity || feat_single_integer") 8 | expect_true(result, info = result$error) 9 | }) 10 | -------------------------------------------------------------------------------- /tests/testthat/test_survivalmodels_surv_loghaz.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | if (!reticulate::py_module_available("torch") || !reticulate::py_module_available("pycox") || 4 | !reticulate::py_module_available("numpy")) { 5 | skip("One of torch, numpy, pycox not available for testing.") 6 | } 7 | 8 | np = reticulate::import("numpy") 9 | torch = reticulate::import("torch") 10 | set.seed(1) 11 | np$random$seed(1L) 12 | torch$manual_seed(1L) 13 | 14 | test_that("autotest", { 15 | learner = lrn("surv.loghaz") 16 | expect_learner(learner) 17 | result = run_autotest(learner, check_replicable = FALSE, exclude = "sanity") 18 | expect_true(result, info = result$error) 19 | }) 20 | -------------------------------------------------------------------------------- /tests/testthat/test_survivalmodels_surv_pchazard.R: -------------------------------------------------------------------------------- 1 | skip_on_os("windows") 2 | 3 | if (!reticulate::py_module_available("torch") || !reticulate::py_module_available("pycox") || 4 | !reticulate::py_module_available("numpy")) { 5 | skip("One of torch, numpy, pycox not available for testing.") 6 | } 7 | 8 | np = reticulate::import("numpy") 9 | torch = reticulate::import("torch") 10 | set.seed(1) 11 | np$random$seed(1L) 12 | torch$manual_seed(1L) 13 | 14 | test_that("autotest", { 15 | learner = lrn("surv.pchazard") 16 | expect_learner(learner) 17 | result = run_autotest(learner, check_replicable = FALSE, exclude = "sanity") 18 | expect_true(result, info = result$error) 19 | }) 20 | -------------------------------------------------------------------------------- /tests/testthat/test_survivalsvm_surv_svm.R: -------------------------------------------------------------------------------- 1 | test_that("autotest", { 2 | learner = LearnerSurvSVM$new() 3 | learner$param_set$values = list(gamma = 0.1) 4 | expect_learner(learner) 5 | result = run_autotest(learner, exclude = "feat_single", check_replicable = FALSE) 6 | expect_true(result, info = result$error) 7 | }) 8 | -------------------------------------------------------------------------------- /vignettes/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | *.R 3 | -------------------------------------------------------------------------------- /vignettes/articles/list_learners.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Search Learners" 3 | output: html_document 4 | --- 5 | 6 | The learner list can now be found on the mlr-org [website](https://mlr-org.com/learners.html). 7 | --------------------------------------------------------------------------------