Skip to contents

This function allows to construct a SurrogateLearner or SurrogateLearnerCollection in the spirit of mlr_sugar from mlr3.

If the archive references more than one target variable or cols_y contains more than one target variable but only a single learner is specified, this learner is replicated as many times as needed to build the SurrogateLearnerCollection.

Usage

srlrn(learner, archive = NULL, cols_x = NULL, cols_y = NULL, ...)

Arguments

learner

(mlr3::LearnerRegr | List of mlr3::LearnerRegr)
mlr3::LearnerRegr that is to be used within the SurrogateLearner or a list of mlr3::LearnerRegr that are to be used within the SurrogateLearnerCollection.

archive

(NULL | bbotk::Archive)
bbotk::Archive of the bbotk::OptimInstance used. Can also be NULL.

cols_x

(NULL | character())
Column ids in the bbotk::Archive that should be used as features. Can also be NULL in which case this is automatically inferred based on the archive.

cols_y

(NULL | character())
Column id(s) in the bbotk::Archive that should be used as a target. If a list of mlr3::LearnerRegr is provided as the learner argument and cols_y is specified as well, as many column names as learners must be provided. Can also be NULL in which case this is automatically inferred based on the archive.

...

(named list())
Named arguments passed to the constructor, to be set as parameters in the paradox::ParamSet.

Examples

library(mlr3)
srlrn(lrn("regr.featureless"), catch_errors = FALSE)
#> <SurrogateLearner>: LearnerRegrFeatureless
#> * Parameters: assert_insample_perf=FALSE, catch_errors=FALSE,
#>   impute_method=random
srlrn(list(lrn("regr.featureless"), lrn("regr.featureless")))
#> <SurrogateLearnerCollection>: (LearnerRegrFeatureless | LearnerRegrFeatureless)
#> * Parameters: assert_insample_perf=FALSE, catch_errors=TRUE,
#>   impute_method=random