Skip to contents

Extract residuals from a machine learning model compared to a `feature_data` object.

Usage

# S4 method for class 'feature_data'
residuals(
  object,
  model,
  subset = c("all", "test", "train"),
  xprep = c("both", "scale", "transform", "none"),
  yprep = c("both", "scale", "transform", "none"),
  to_original_scale = FALSE,
  as_matrix = TRUE,
  ...
)

Arguments

object

A `feature_data` object.

model

A fitted model object.

subset

Subset of the `preproc` data set.

xprep

Character argument if transformed data ("transform"), scaled data ("scale" ), transformed and scaled data ("both") or original raw data ("none") are used for x.

yprep

Character argument if transformed data ("transform"), scaled data ("scale" ), transformed and scaled data ("both") or original raw data ("none") are used for y.

to_original_scale

Logical value to force re-transformation of predictions to the original scale.

as_matrix

logical TRUE if the function should return matrix, or a data frame or tibble otherwise.

...

Additional arguments (currently not used).

Value

A matrix or vector with the residuals.

Details

Currently only certain Keras models can be used as fitted models.