mlr_test_helpers {mlr3}R Documentation

Documentation of mlr3 test helpers

Description

The mlr3 package contains various helper functions to test the validity of objects such as learners. These functions are not contained in the mlr3 namespaces and are instead located in the inst/testthat directory of the source package or the testthat directory of the installed package.

These files can be sourced with the following line of code:

lapply(list.files(system.file("testthat", package = "mlr3"), pattern = "^helper.*\\.[rR]", full.names = TRUE), source)

Other extension packages such as mlr3proba have similar files that can be sourced accordingly.

This manual page documents the most important helper functions that are relevant when users implement their own custom learners.

run_autotest()

This function runs a Learner's automatic test suite.

During the autotests, multiple tasks are generated depending on the properties of the learner. The run_autotest() function then trains the learner on each task and predicts with all supported predict types. (see argument predict_types). To debug, simply run result = run_autotest(learner) and proceed with investigating the task, learner and prediction of the returned result.

For example usages you can look at the autotests in various mlr3 source repositories such as mlr3learners.

Parameters:

run_paramtest()

Description:

Checks parameters of mlr3 Learners against parameters defined in the upstream functions of the respective learner. The goal is to detect if parameters have been dropped or added in the upstream implementation. Some learners do not have all of their parameters stored within the learner function that is called during training. Sometimes learners come with a "control" function, e.g. glmnet.control() from package glmnet. Such learners need to be checked as well since they make up the full ParamSet of the respective learner.

To work nicely with the defined ParamSet, certain parameters need to be excluded because these are only present in either the "control" object or the actual top-level function call. Such exclusions should go into argument exclude with a comment for the reason of the exclusion. See examples for more information.

For example usages you can look at the parameter tests in various mlr3 source repositories such as mlr3learners.

Parameters:

expect_learner()

Checks various properties that learners have to satisfy. Used for testing learner implementations, especially if all methods and fields are implement as document.

Parameters


[Package mlr3 version 0.19.0 Index]