LearnerRegr: Regression Learner

LearnerRegrR Documentation

Regression Learner

Description

This Learner specializes Learner for regression problems:

  • task_type is set to "regr".

  • Creates Predictions of class PredictionRegr.

  • Possible values for predict_types are:

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

    • "se": Predicts the standard error for each value of response for each observation in the test set.

    • "distr": Probability distribution as VectorDistribution object (requires package distr6, available via repository https://raphaels1.r-universe.dev).

  • "quantiles": Predicts quantile estimates for each observation in the test set. Set ⁠$quantiles⁠ to specify the quantiles to predict and ⁠$quantile_response⁠ to specify the response quantile. See the mlr3book on quantile regression for more details.

Predefined learners can be found in the dictionary mlr_learners. Essential regression learners can be found in this dictionary after loading mlr3learners. Additional learners are implemented in the Github package https://github.com/mlr-org/mlr3extralearners.

Super class

Learner -> LearnerRegr

Active bindings

quantiles

(numeric())
Numeric vector of probabilities to be used while predicting quantiles. Elements must be between 0 and 1, not missing and provided in ascending order. If only one quantile is provided, it is used as response. Otherwise, set ⁠$quantile_response⁠ to specify the response quantile. Set to NULL to reset both ⁠$quantiles⁠ and ⁠$quantile_response⁠.

quantile_response

(numeric(1))
The quantile to be used as response.

Methods

Public methods

Inherited methods

LearnerRegr$new()

Creates a new instance of this R6 class.

Usage
LearnerRegr$new(
  id,
  task_type = "regr",
  param_set = ps(),
  predict_types = "response",
  feature_types = character(),
  properties = character(),
  packages = character(),
  label = NA_character_,
  man = NA_character_
)
Arguments
id

(character(1))
Identifier for the new instance.

task_type

(character(1))
Type of task, e.g. "regr" or "classif". Must be an element of mlr_reflections$task_types$type.

param_set

(paradox::ParamSet)
Set of hyperparameters.

predict_types

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

feature_types

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

properties

(character())
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.

  • "offset": The learner can incorporate offset values to adjust predictions.

  • "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).

  • "validation": The learner can use a validation task during training.

  • "internal_tuning": The learner is able to internally optimize hyperparameters (those are also tagged with "internal_tuning").

  • "marshal": To save learners with this property, you need to call ⁠$marshal()⁠ first. If a learner is in a marshaled state, you call first need to call ⁠$unmarshal()⁠ to use its model, e.g. for prediction.

  • "hotstart_forward": The learner supports to hotstart a model forward.

  • "hotstart_backward": The learner supports hotstarting a model backward.

  • '"featureless": The learner does not use features.

packages

(character())
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

(character(1))
Label for the new instance.

man

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


LearnerRegr$predict_newdata_fast()

Predicts outcomes for new data in newdata using the model fitted during ⁠$train()⁠. This method is faster than ⁠$predict_newdata()⁠ as it skips assertions, type conversions, encapsulation, and logging. The learner must be trained before calling this method.

Unlike ⁠$predict_newdata()⁠, this method does not return a Prediction object. Instead, it returns a list with either a "response", "se", or "quantiles" element, depending on the prediction type.

Note that state$predict_time and state$log will remain empty after using this method. Some learners may not support this method and may fail when it is called. Prefer ⁠$predict_newdata()⁠ unless performance is critical.

If the model was trained via resample() or benchmark(), you must pass the associated task object stored in the corresponding ResampleResult or BenchmarkResult.

Usage
LearnerRegr$predict_newdata_fast(newdata, task = NULL)
Arguments
newdata

data.table::data.table()
New data to predict on.

task

(Task).

Returns

list() with elements "response", "se" or "quantiles" depending on the predict type.


LearnerRegr$clone()

The objects of this class are cloneable with this method.

Usage
LearnerRegr$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

See Also

Other Learner: Learner, LearnerClassif, 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

Examples

# get all regression learners from mlr_learners:
lrns = mlr_learners$mget(mlr_learners$keys("^regr"))
names(lrns)

# get a specific learner from mlr_learners:
mlr_learners$get("regr.rpart")
lrn("regr.featureless")

mlr3 documentation built on June 11, 2026, 5:08 p.m.