evaluate_residuals: Evaluate residuals from a regression task

View source: R/evaluate_residuals.R

evaluate_residualsR Documentation

Evaluate residuals from a regression task

Description

\Sexpr[results=rd, stage=render]{lifecycle::badge("experimental")}

Calculates a large set of error metrics from regression residuals.

Note: In most cases you should use evaluate() instead. It works in magrittr pipes (e.g. %>%) and with dplyr::group_by(). evaluate_residuals() is more lightweight and may be preferred in programming when you don't need the extra stuff in evaluate().

Usage

evaluate_residuals(data, target_col, prediction_col, metrics = list())

Arguments

data

data.frame with predictions and targets.

target_col

Name of the column with the true values in `data`.

prediction_col

Name of column with the predicted values in `data`.

metrics

list for enabling/disabling metrics.

E.g. list("RMSE" = FALSE) would disable RMSE. Default values (TRUE/FALSE) will be used for the remaining available metrics.

You can enable/disable all metrics at once by including "all" = TRUE/FALSE in the list. This is done prior to enabling/disabling individual metrics, why for instance list("all" = FALSE, "RMSE" = TRUE) would return only the RMSE metric.

The list can be created with gaussian_metrics().

Also accepts the string "all".

Details

The metric formulas are listed in 'The Available Metrics' vignette.

Value

tibble data.frame with the calculated metrics.

The following metrics are available (see `metrics`):

Metric Name Default
Mean Absolute Error "MAE" Enabled
Root Mean Square Error "RMSE" Enabled
Normalized RMSE (by target range) "NRMSE(RNG)" Disabled
Normalized RMSE (by target IQR) "NRMSE(IQR)" Enabled
Normalized RMSE (by target STD) "NRMSE(STD)" Disabled
Normalized RMSE (by target mean) "NRMSE(AVG)" Disabled
Relative Squared Error "RSE" Disabled
Root Relative Squared Error "RRSE" Enabled
Relative Absolute Error "RAE" Enabled
Root Mean Squared Log Error "RMSLE" Enabled
Mean Absolute Log Error "MALE" Disabled
Mean Absolute Percentage Error "MAPE" Disabled
Mean Squared Error "MSE" Disabled
Total Absolute Error "TAE" Disabled
Total Squared Error "TSE" Disabled

The Name column refers to the name used in the package. This is the name in the output and when enabling/disabling in `metrics`.

Author(s)

Ludvig Renbo Olsen, r-pkgs@ludvigolsen.dk

See Also

Other evaluation functions: binomial_metrics(), confusion_matrix(), evaluate(), gaussian_metrics(), multinomial_metrics()

Examples

# Attach packages
library(cvms)

data <- data.frame(
  "targets" = rnorm(100, 14.7, 3.6),
  "predictions" = rnorm(100, 13.2, 4.6)
)

evaluate_residuals(
  data = data,
  target_col = "targets",
  prediction_col = "predictions"
)

cvms documentation built on Sept. 11, 2024, 6:22 p.m.