evaluate_residuals {cvms}R Documentation

Evaluate residuals from a regression task



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().


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



data.frame with predictions and targets.


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


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


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".


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


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`.


Ludvig Renbo Olsen, r-pkgs@ludvigolsen.dk

See Also

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


# Attach packages

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

  data = data,
  target_col = "targets",
  prediction_col = "predictions"

[Package cvms version 1.3.3 Index]