Add black box predictions to generated dataset

add_predictions2(to_explain, black_box_model, data = NULL,
  predict_fun = predict, hyperparams = list(), ...)

Arguments

to_explain

List return by sample_locally2 function.

black_box_model

String with mlr signature of a learner or a model with predict interface.

data

Original data frame used to generate new dataset. Need not be provided when a trained model is passed in black_box_model argument.

predict_fun

Either a "predict" function that returns a vector of the same type as response or custom function that takes a model as a first argument, and data used to calculate predictions as a second argument and returns a vector of the same type as respone. Will be used only if a model object was provided in the black_box argument.

hyperparams

Optional list of (hyper)parameters to be passed to mlr::makeLearner.

...

Additional parameters to be passed to predict function.

Value

list consisting of

data

Dataset generated by sample_locally2 function with response variable.

target

Name of the response variable.

model

Black box model which is being explained.

explained_instance

Instance that is being explained.

Examples

# NOT RUN {
local_exploration1 <- add_predictions2(wine, dataset_for_local_exploration,
                                      black_box_model = "regr.svm")
# Pass trained model to the function.
svm_model <- svm(quality ~., data = wine)
local_exploration2 <- add_predictions2(wine, dataset_for_local_exploration,
                                      black_box_model = svm_model)
# }