R/predict_surrogate.R
changed.
Other files ignored by Codecov
8 | 8 | #' @param ... other parameters that will be passed to |
|
9 | 9 | #' @param type which implementation of thee LIME method should be used. Either \code{localModel} (default), \code{lime} or \code{iml}. |
|
10 | 10 | #' @param n_features will be passed to the lime implementation, by default 4 |
|
11 | + | #' @param k will be passed to the iml implementation, by default 4 |
|
11 | 12 | #' @param n_permutations will be passed to the lime implementation, by default 1000 |
|
12 | 13 | #' @param size will be passed to the localModel implementation, by default 1000 |
|
13 | 14 | #' @param seed seed for random number generator, by default 1313 |
83 | 84 | lime::plot_features(x, ...) |
|
84 | 85 | } |
|
85 | 86 | ||
87 | + | ||
88 | + | #' @import iml |
|
86 | 89 | #' @name predict_surrogate |
|
87 | 90 | #' @export |
|
88 | - | predict_surrogate_iml <- function(explainer, new_observation, ...) { |
|
89 | - | ||
91 | + | predict_surrogate_iml <- function(explainer, new_observation, k = 4, ...) { |
|
92 | + | iml_model <- Predictor$new(model = explainer$model, data = explainer$data[,colnames(new_observation)]) |
|
93 | + | LocalModel$new(predictor = iml_model, x.interest = new_observation, k = k) |
|
90 | 94 | } |
Files | Coverage |
---|---|
R | 84.70% |
Project Totals (7 files) | 84.70% |
1 |
comment: false |