3.3 Learners

Objects of class mlr3::Learner provide a unified interface to many popular machine-learning algorithms in R. They consist of methods to train and predict on a mlr3::Task, and additionally provide meta information about the algorithms.

The package ships with only a rather minimal set of classification and regression learners, more are implemented in the mlr3learners package. Furthermore, mlr3learners has some documentation on creating custom learners.

3.3.1 Predefined Learners

Similar to mlr3::mlr_tasks, the mlr3misc::Dictionary mlr3::mlr_learners can be queried for available learners:

As listed in the output, each learner comes with the following information:

  • feature_types: what kind of features can be processed.
  • packages: which packages are required to run train() and predict().
  • properties: additional properties and capabilities. For example, a learner has the property “missings” if it is able to handle missing values, and “importance” if it is possible to extract feature importance values.
  • predict_types: what predict types are possible. For example, a classification learner can predict labels (“response”) or probabilities (“prob”).

To extract a specific learner, use the corresponding "id":

In the output we see that all information from the previous table is also accessible via public slots (id, feature_types, packages, properties, predict_types). Additionally, predict_type returns the currently selected predict type of the learner.

Slot param_set stores a description of hyperparameter settings:

The set of hyperparameter values is stored inside the parameter set in the values slot. By assigning a named list to this slot, we change the active hyperparameters of the learner:

The slot model stores the result of the training step. As we have not yet trained a model, this slot is NULL: