Add black box predictions to generated dataset
add_predictions2(to_explain, black_box_model, data = NULL, predict_fun = predict, hyperparams = list(), ...)
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. |
list consisting of
Dataset generated by sample_locally2 function with response variable.
Name of the response variable.
Black box model which is being explained.
Instance that is being explained.
# 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) # }