local_approximation: Fit local model around the observation: shortcut for DALEX...

Description Usage Arguments Value Examples

View source: R/dalex_shortcut.R

Description

Fit local model around the observation: shortcut for DALEX explainer objects

Usage

1
2
3
local_approximation(explainer, observation, target_variable_name,
  n_new_obs, local_model = "regr.lm", select_variables = F,
  predict_type = "response", kernel_type = gaussian_kernel, ...)

Arguments

explainer

a model to be explained, preprocessed by the DALEX::explain function

observation

a new observation for which predictions need to be explained

target_variable_name

name of the response variablea as a character

n_new_obs

Number of observation in the simulated dataset

local_model

Character specyfing mlr learner to be used as a local model

select_variables

If TRUE, variable selection will be performed while fitting the local linear model

predict_type

Argument passed to mlr::makeLearner() argument "predict.type" while fitting the local model. Defaults to "response"

kernel_type

Function which will be used to calculate distances from simulated observation to explained instance

...

Arguments to be passed to sample_locally function

Value

object of class live_explainer. More details in fit_explanation function help.

Examples

1
2
3
4
5
6
7
8
9
## Not run: 
data('wine')
library(randomForest)
library(DALEX)
rf <- randomForest(quality~., data = wine)
expl <- explain(rf, wine, wine$quality)
live_expl <- local_approximation(expl, wine[5, ], "quality", 500)

## End(Not run)

MI2DataLab/live documentation built on Aug. 21, 2019, 6:05 p.m.