Skip to contents

This Learner specializes Learner for classification problems:

  • task_type is set to "classif".

  • Creates Predictions of class PredictionClassif.

  • Possible values for predict_types are:

    • "response": Predicts a class label for each observation in the test set.

    • "prob": Predicts the posterior probability for each class for each observation in the test set.

  • Additional learner properties include:

    • "twoclass": The learner works on binary classification problems.

    • "multiclass": The learner works on multiclass classification problems.

Predefined learners can be found in the dictionary mlr_learners. Essential classification learners can be found in this dictionary after loading mlr3learners. Additional learners are implement in the Github package

See also

Other Learner: Learner, LearnerRegr, mlr_learners, mlr_learners_classif.debug, mlr_learners_classif.featureless, mlr_learners_classif.rpart, mlr_learners_regr.debug, mlr_learners_regr.featureless, mlr_learners_regr.rpart

Super class

mlr3::Learner -> LearnerClassif


Inherited methods

Method new()

Creates a new instance of this R6 class.


  param_set = ps(),
  predict_types = "response",
  feature_types = character(),
  properties = character(),
  data_formats = "data.table",
  packages = character(),
  label = NA_character_,
  man = NA_character_



Identifier for the new instance.


Set of hyperparameters.


Supported predict types. Must be a subset of mlr_reflections$learner_predict_types.


Feature types the learner operates on. Must be a subset of mlr_reflections$task_feature_types.


Set of properties of the Learner. Must be a subset of mlr_reflections$learner_properties. The following properties are currently standardized and understood by learners in mlr3:

  • "missings": The learner can handle missing values in the data.

  • "weights": The learner supports observation weights.

  • "importance": The learner supports extraction of importance scores, i.e. comes with an $importance() extractor function (see section on optional extractors in Learner).

  • "selected_features": The learner supports extraction of the set of selected features, i.e. comes with a $selected_features() extractor function (see section on optional extractors in Learner).

  • "oob_error": The learner supports extraction of estimated out of bag error, i.e. comes with a oob_error() extractor function (see section on optional extractors in Learner).


Set of supported data formats which can be processed during $train() and $predict(), e.g. "data.table".


Set of required packages. A warning is signaled by the constructor if at least one of the packages is not installed, but loaded (not attached) later on-demand via requireNamespace().


Label for the new instance.


String in the format [pkg]::[topic] pointing to a manual page for this object. The referenced help package can be opened via method $help().

Method clone()

The objects of this class are cloneable with this method.


LearnerClassif$clone(deep = FALSE)



Whether to make a deep clone.


# get all classification learners from mlr_learners:
lrns = mlr_learners$mget(mlr_learners$keys("^classif"))
#> [1] "classif.debug"       "classif.featureless" "classif.rpart"      

# get a specific learner from mlr_learners:
lrn = lrn("classif.rpart")
#> <LearnerClassifRpart:classif.rpart>: Classification Tree
#> * Model: -
#> * Parameters: xval=0
#> * Packages: mlr3, rpart
#> * Predict Types:  [response], prob
#> * Feature Types: logical, integer, numeric, factor, ordered
#> * Properties: importance, missings, multiclass, selected_features,
#>   twoclass, weights

# train the learner:
task = tsk("penguins")
lrn$train(task, 1:200)

# predict on new observations:
lrn$predict(task, 201:344)$confusion
#>            truth
#> response    Adelie Chinstrap Gentoo
#>   Adelie         0        62      1
#>   Chinstrap      0         0      0
#>   Gentoo         0         6     75