Learn R Programming

mlr (version 2.9)

makeMeasure: Construct performance measure.

Description

A measure object encapsulates a function to evaluate the performance of a prediction. Information about already implemented measures can be obtained here: measures.

A learner is trained on a training set d1, results in a model m and predicts another set d2 (which may be a different one or the training set) resulting in the prediction. The performance measure can now be defined using all of the information of the original task, the fitted model and the prediction.

Object slots:

Usage

makeMeasure(id, minimize, properties = character(0L), fun, extra.args = list(), aggr = test.mean, best = NULL, worst = NULL, name = id, note = "")

Arguments

id
[character(1)] Name of measure.
minimize
[logical(1)] Should the measure be minimized? Default is TRUE.
properties
[character] Set of measure properties. Some standard property names include:

Default is character(0).

fun
[function(task, model, pred, feats, extra.args)] Calculates the performance value. Usually you will only need the prediction object pred.
extra.args
[list] List of extra arguments which will always be passed to fun. Default is empty list.
aggr
[Aggregation] Aggregation funtion, which is used to aggregate the values measured on test / training sets of the measure to a single value. Default is test.mean.
best
[numeric(1)] Best obtainable value for measure. Default is -Inf or Inf, depending on minimize.
worst
[numeric(1)] Worst obtainable value for measure. Default is Inf or -Inf, depending on minimize.
name
[character] Name of the measure. Default is id.
note
[character] Description and additional notes for the measure. Default is “”.

Value

[Measure].

See Also

Other performance: estimateRelativeOverfitting, makeCostMeasure, makeCustomResampledMeasure, measures, performance

Examples

Run this code
f = function(task, model, pred, extra.args)
  sum((pred$data$response - pred$data$truth)^2)
makeMeasure(id = "my.sse", minimize = TRUE, properties = c("regr", "response"), fun = f)

Run the code above in your browser using DataLab