R/regr_mae.R

Defines functions mae

Documented in mae

#' @title Mean Absolute Error
#'
#' @details
#' The Mean Absolute Error is defined as \deqn{
#'   \frac{1}{n} \sum_{i=1}^n w_i \left| t_i - r_i \right|.
#' }{
#'   weighted.mean(abs(t - r), w).
#' }
#'
#' @templateVar mid mae
#' @template regr_template
#'
#' @inheritParams regr_params
#' @template regr_example
#' @export
mae = function(truth, response, sample_weights = NULL, ...) {
  assert_regr(truth, response = response)
  wmean(.ae(truth, response), sample_weights)
}

#' @include measures.R
add_measure(mae, "Mean Absolute Error", "regr", 0, Inf, TRUE, obs_loss = "ae")

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.