View source: R/light_global_surrogate.R
light_global_surrogate | R Documentation |
Model predictions are modelled by a single decision tree, serving as an easy
to interprete surrogate to the original model.
As suggested in Molnar (see reference below), the quality of the surrogate
tree can be measured by its R-squared. The size of the tree can be modified
by passing ...
arguments to rpart::rpart()
.
light_global_surrogate(x, ...)
## Default S3 method:
light_global_surrogate(x, ...)
## S3 method for class 'flashlight'
light_global_surrogate(
x,
data = x$data,
by = x$by,
v = NULL,
use_linkinv = TRUE,
n_max = Inf,
seed = NULL,
keep_max_levels = 4L,
...
)
## S3 method for class 'multiflashlight'
light_global_surrogate(x, ...)
x |
An object of class "flashlight" or "multiflashlight". |
... |
Arguments passed to |
data |
An optional |
by |
An optional vector of column names used to additionally group the results. For each group, a separate tree is grown. |
v |
Vector of variables used in the surrogate model.
Defaults to all variables in |
use_linkinv |
Should retransformation function be applied? Default is |
n_max |
Maximum number of data rows to consider to build the tree. |
seed |
An integer random seed used to select data rows if |
keep_max_levels |
Number of levels of categorical and factor variables to keep.
Other levels are combined to a level "Other". This prevents |
An object of class "light_global_surrogate" with the following elements:
data
A tibble with results. Can be used to build fully customized visualizations.
Column names can be controlled by options(flashlight.column_name)
.
by
Same as input by
.
light_global_surrogate(default)
: Default method not implemented yet.
light_global_surrogate(flashlight)
: Surrogate model for a flashlight.
light_global_surrogate(multiflashlight)
: Surrogate model for a multiflashlight.
Molnar C. (2019). Interpretable Machine Learning.
plot.light_global_surrogate()
fit <- lm(Sepal.Length ~ ., data = iris)
x <- flashlight(model = fit, label = "lm", data = iris)
light_global_surrogate(x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.