Closed mstaniak closed 5 years ago
I'm trying to use lime with a 1-d model as a toy example and I'm getting this error. (Based on an example in Christoph Molnar's IML book)
set.seed(17) x <- runif(1000, -8, 8) y <- ifelse(x <= 1, (x + 3)^2 - 10 , -5*x + 11) molnar <- data.frame(x = x, y = y) true_model <- function(model, newdata) { ifelse(newdata$x <= 1, (newdata$x + 3)^2 - 10 , -5*newdata$x + 11) } true_model(list(), data.frame(x = c(0, 10))) library(lime) lime_wr <- lime(molnar, list()) model_type.list <- function(x, ...) "regression" predict_model.list <- function(x, newdata, type, ...) true_model(x, newdata) lime_expl <- lime::explain(data.frame(x = -6, y = 2), lime_wr, n_features = 2) # Error in case_res[i, , drop = FALSE] : incorrect number of dimensions
lime expects the output to be a data.frame, not a vector. see ?model_support for how to format the output of true_model()
?model_support
true_model()
I'm trying to use lime with a 1-d model as a toy example and I'm getting this error. (Based on an example in Christoph Molnar's IML book)