Creates or updates a "flashlight" object. If a flashlight is to be created,
all arguments are optional except label
. If a flashlight is to be updated,
all arguments are optional up to x
(the flashlight to be updated).
flashlight(x, ...)
# Default S3 method
flashlight(
x,
model = NULL,
data = NULL,
y = NULL,
predict_function = stats::predict,
linkinv = function(z) z,
w = NULL,
by = NULL,
metrics = list(rmse = MetricsWeighted::rmse),
label = NULL,
shap = NULL,
...
)
# S3 method for class 'flashlight'
flashlight(x, check = TRUE, ...)
An object of class "flashlight". If not provided, a new flashlight is
created based on further input. Otherwise, x
is updated based on further input.
Arguments passed from or to other functions.
A fitted model of any type. Most models require a customized
predict_function
.
A data.frame
or tibble
used as basis for calculations.
Variable name of response.
A real valued function with two arguments:
A model and a data of the same structure as data
.
Only the order of the two arguments matter, not their names.
An inverse transformation function applied after predict_function
.
A variable name of case weights.
A character vector with names of grouping variables.
A named list of metrics. Here, a metric is a function with exactly
four arguments: actual, predicted, w (case weights) and ...
like those in package MetricsWeighted.
Name of the flashlight. Required.
An optional shap object. Typically added by calling add_shap()
.
When updating the flashlight: Should internal checks be performed?
Default is TRUE
.
An object of class "flashlight" (and list
) containing each
input (except x
) as element.
flashlight(default)
: Used to create a flashlight object.
No x
has to be passed in this case.
flashlight(flashlight)
: Used to update an existing flashlight object.
fit <- lm(Sepal.Length ~ ., data = iris)
(fl <- flashlight(model = fit, data = iris, y = "Sepal.Length", label = "ols"))
#>
#> Flashlight ols
#>
#> Model: Yes
#> y: Sepal.Length
#> w: No
#> by: No
#> data dim: 150 5
#> metrics: rmse
(fl_updated <- flashlight(fl, linkinv = exp))
#>
#> Flashlight ols
#>
#> Model: Yes
#> y: Sepal.Length
#> w: No
#> by: No
#> data dim: 150 5
#> metrics: rmse