This is the abstract base class for measures like MeasureClassif and MeasureRegr.

Measures are classes around tailored around two functions:

  1. A function score which quantifies the performance by comparing true and predicted response.

  2. A function aggregator which combines multiple performance scores returned by calculate to a single numeric value.

In addition to these two functions, meta-information about the performance measure is stored.

Predefined measures are stored in the mlr3misc::Dictionary mlr_measures, e.g. classif.auc or time_train. A guide on how to extend mlr3 with custom measures can be found in the mlr3book.


R6::R6Class object.


Note: This object is typically constructed via a derived classes, e.g. MeasureClassif or MeasureRegr.

m = Measure$new(id, task_type = NA, range = c(-Inf, Inf), minimize = NA, average = "macro",
    aggregator = NULL, properties = character(), predict_type = "response", predict_sets = "test",
    task_properties = character(), packages = character(), man = NA_character_)
  • id :: character(1)
    Identifier for the measure.

  • task_type :: character(1)
    Type of the task the measure can operator on. E.g., "classif" or "regr".

  • range :: numeric(2)
    Feasible range for this measure as c(lower_bound, upper_bound). Both bounds may be infinite.

  • minimize :: logical(1)
    Set to TRUE if good predictions correspond to small values, and to FALSE if good predictions correspond to large values. If set to NA (default), tuning this measure is not possible.

  • average :: character(1)
    How to average multiple Predictions from a ResampleResult.

    The default, "macro", calculates the individual performances scores for each Prediction and then uses the function defined in aggregator to average them to a single number.

    If set to "micro", the individual Prediction objects are first combined into a single new Prediction object which is then used to assess the performance. The function aggregator is not used in this case.

  • aggregator :: function(x)
    Function to aggregate individual performance scores x where x is a numeric vector. If NULL, defaults to mean().

  • properties :: character()
    Properties of the measure. Must be a subset of mlr_reflections$measure_properties. Supported by mlr3:

    • "requires_task" (requires the complete Task),

    • "requires_learner" (requires the trained Learner),

    • "requires_train_set" (requires the training indices from the Resampling), and

    • "na_score" (the measure is expected to occasionally return NA).

  • predict_type :: character(1)
    Required predict type of the Learner. Possible values are stored in mlr_reflections$learner_predict_types.

  • predict_sets :: character()
    Prediction sets to operate on, used in aggregate() to extract the matching predict_sets from the ResampleResult. Multiple predict sets are calculated by the respective Learner during resample()/benchmark(). Must be a non-empty subset of c("train", "test"). If multiple sets are provided, these are first combined to a single prediction object. Default is "test".

  • task_properties :: character()
    Required task properties, see Task.

  • packages :: character()
    Set of required packages. Note that these packages will be loaded via requireNamespace(), and are not attached.

  • man :: character(1)
    String in the format [pkg]::[topic] pointing to a manual page for this object.


All variables passed to the constructor.


See also