light_effects {flashlight} | R Documentation |
Combination of Response, Predicted, Partial Dependence, and ALE profiles.
Description
Calculates response- prediction-, partial dependence, and ALE profiles of a
(multi-)flashlight with respect to a covariable v
.
Usage
light_effects(x, ...)
## Default S3 method:
light_effects(x, ...)
## S3 method for class 'flashlight'
light_effects(
x,
v,
data = NULL,
by = x$by,
stats = c("mean", "quartiles"),
breaks = NULL,
n_bins = 11L,
cut_type = c("equal", "quantile"),
use_linkinv = TRUE,
counts_weighted = FALSE,
v_labels = TRUE,
pred = NULL,
pd_indices = NULL,
pd_n_max = 1000L,
pd_seed = NULL,
ale_two_sided = TRUE,
...
)
## S3 method for class 'multiflashlight'
light_effects(
x,
v,
data = NULL,
breaks = NULL,
n_bins = 11L,
cut_type = c("equal", "quantile"),
...
)
Arguments
x |
An object of class "flashlight" or "multiflashlight". |
... |
Further arguments passed to |
v |
The variable name to be profiled. |
data |
An optional |
by |
An optional vector of column names used to additionally group the results. |
stats |
Statistic to calculate for the response profile: "mean" or "quartiles". |
breaks |
Cut breaks for a numeric |
n_bins |
Approximate number of unique values to evaluate for numeric |
cut_type |
Should a numeric |
use_linkinv |
Should retransformation function be applied? Default is |
counts_weighted |
Should counts be weighted by the case weights?
If |
v_labels |
If |
pred |
Optional vector with predictions (after application of inverse link).
Can be used to avoid recalculation of predictions over and over if the functions
is to be repeatedly called for different |
pd_indices |
A vector of row numbers to consider in calculating partial dependence profiles and "ale". |
pd_n_max |
Maximum number of ICE profiles to calculate (will be randomly
picked from |
pd_seed |
Integer random seed used to select ICE profiles for partial dependence and ALE. |
ale_two_sided |
If |
Details
Note that ALE profiles are being calibrated by (weighted) average predictions. The resulting level might be quite different from the one of the partial dependence profiles.
Value
An object of class "light_effects" with the following elements:
-
response
: A tibble containing the response profiles. Column names can be controlled byoptions(flashlight.column_name)
. -
predicted
: A tibble containing the prediction profiles. -
pd
: A tibble containing the partial dependence profiles. -
ale
: A tibble containing the ALE profiles. -
by
: Same as inputby
. -
v
: The variable(s) evaluated. -
stats
: Same as inputstats
.
Methods (by class)
-
light_effects(default)
: Default method. -
light_effects(flashlight)
: Profiles for a flashlight object. -
light_effects(multiflashlight)
: Effect profiles for a multiflashlight object.
See Also
light_profile()
, plot.light_effects()
Examples
fit <- lm(Sepal.Length ~ ., data = iris)
fl <- flashlight(model = fit, label = "iris", data = iris, y = "Sepal.Length")
light_effects(fl, v = "Species")