set.seed(17)
x <- runif(1000, -10, 10)
y <- 0.05*x^2
quadratic <- data.frame(x = x,
y = y)
true_model <- function(model, newdata) 0.05*(newdata$x)^2
library(iml)
mp = Predictor$new(list(), data = quadratic[, "x", drop = FALSE],
predict.fun = true_model)
shapley = Shapley$new(mp, x.interest = data.frame(x = -6))
lime_expl_iml <- LocalModel$new(mp, x.interest = data.frame(x = -6), k = 1)
and both calls (Shapley$new and LocalModel$new) results in an error when there is just a single predictor.
The errors are:
Assertion on 'prediction' failed: Must have exactly 1 rows, but has 0 rows.
Error in self$predictor$data$match_cols(data.frame(newdata)) :
Missing columns: V1
I'm aware that it's an unusual setting, but playing with such simple models is very instructive.
I excluded the case where there is only one predictor, since none of the interpretation methods is meaningful in that case. It should throw a more meaningful error though.
I'm running some toy examples like the one below:
and both calls (Shapley$new and LocalModel$new) results in an error when there is just a single predictor. The errors are:
I'm aware that it's an unusual setting, but playing with such simple models is very instructive.