Skip to contents

Compute the mean absolute error of the predictions of a model.

Usage

EvaluatorMAE(.prediction, .data, .target)

Arguments

.prediction

A data.frame object containing the predictions of a model. The columns should contain the predictions and the true values. If only the predictions are handed over, the true values of the target variable have to be handed over in the .data argument and the name of the variable has to be handed over in .target.

.data

Optional argument, which has to be provided if only the predictions are handed over in .prediction, .data has to be a data.frame which contains the true values.

.target

If only the predictions are handed over in .prediction, .target has to be set and is the name of the target variable that was predicted, handed over as a character of length 1.

Value

The mean absolute error of the predictions.

Examples

x <- data.frame(var1 = c(1, 1, 1, 1, 0), target = c(1, 2, 3, 4, 5))
predictions <- c(3)
EvaluatorMAE(predictions, x, "target")
#> [1] 1.2
predictions <- data.frame(prediction = c(1.3, 2.5, 2.6, 3.5, 4.5), truth = c(1, 2, 3, 4, 5))
EvaluatorMAE(predictions)
#> [1] 0.44