/mlr3extralearners

Extra learners for use in mlr3.

Primary LanguageR

mlr3extralearners

Package website: release | dev

Extra Learners for mlr3.

RCMD Check StackOverflow Mattermost

What is mlr3extralearners?

mlr3extralearners contains all learners from mlr3 that are not in mlr3learners or the core packages. An overview of all learners within the mlr3verse can be found here.

mlr3extralearners lives on GitHub and will not be on CRAN.

You can install the latest release using the code below

remotes::install_github("mlr-org/mlr3extralearners@*release")

Alternatively, you can add the following to your .Rprofile, which allows you to install mlr3extralearners via install.packages().

# .Rprofile
options(repos = c(
  mlrorg = "https://mlr-org.r-universe.dev",
  CRAN = "https://cloud.r-project.org/"
))

Installing and Loading Learners

The package includes functionality for detecting if you have the required packages installed to use a learner, and ships with the function install_learner which can install all required learner dependencies.

lrn("regr.gbm")
#> Warning: Package 'gbm' required but not installed for Learner 'regr.gbm'
#> <LearnerRegrGBM:regr.gbm>: Gradient Boosting
#> * Model: -
#> * Parameters: keep.data=FALSE, n.cores=1
#> * Packages: mlr3, mlr3extralearners, gbm
#> * Predict Types:  [response]
#> * Feature Types: integer, numeric, factor, ordered
#> * Properties: importance, missings, weights

install_learners("regr.gbm")

lrn("regr.gbm")
#> <LearnerRegrGBM:regr.gbm>: Gradient Boosting
#> * Model: -
#> * Parameters: keep.data=FALSE, n.cores=1
#> * Packages: mlr3, mlr3extralearners, gbm
#> * Predict Types:  [response]
#> * Feature Types: integer, numeric, factor, ordered
#> * Properties: importance, missings, weights

Extending mlr3extralearners

New learners - either for personal use or to extend mlr3extralearners - can be created with the create_learner function. An in-depth tutorial on how to do this can be found in the mlr3 book.