Add black box predictions to generated dataset
add_predictions(to_explain, black_box_model, data = NULL, predict_fun = predict, hyperparams = list(), ...)
to_explain | List return by sample_locally 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 of class "live_explorer" consisting of
Dataset generated by sample_locally function with response variable.
Name of the response variable.
Black box model which is being explained.
Instance that is being explained.
Name of used sampling method
Names of variables which were not sampled
Standard deviations of numerical variables
# NOT RUN { # Train a model inside add_predictions call. local_exploration1 <- add_predictions(dataset_for_local_exploration, black_box_model = "regr.svm", data = wine) # Pass trained model to the function. svm_model <- svm(quality ~., data = wine) local_exploration2 <- add_predictions(dataset_for_local_exploration, black_box_model = svm_model) # }