Fit local model around the observation: shortcut for DALEX explainer objects
local_approximation(explainer, observation, target_variable_name, n_new_obs, local_model = "regr.lm", select_variables = F, predict_type = "response", kernel_type = gaussian_kernel, ...)
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 |
object of class live_explainer. More details in fit_explanation function help.
# 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) # }