R/regr_ae.R

Defines functions .ae ae

Documented in ae

#' @title Absolute Error (per observation)
#'
#' @description
#' Calculates the per-observation absolute error as \deqn{
#'   \left| t_i - r_i \right|.
#' }{
#'   abs(t - r).
#' }
#'
#' @templateVar mid ae
#' @template regr_template
#' @inheritParams regr_params
#'
#' @export
ae = function(truth, response, ...) {
  assert_regr(truth, response)
  .ae(truth, response)
}

.ae = function(truth, response) {
  abs(truth - response)
}

#' @include measures.R
add_measure(ae, "Absolute Error (per observation)", "regr", 0, Inf, TRUE, aggregated = FALSE)

Try the mlr3measures package in your browser

Any scripts or data that you put into this service are public.

mlr3measures documentation built on Aug. 5, 2022, 5:22 p.m.