Hi, after I fitted a local surrogate model with LocalModel to explain the prediction of a point of interest, I wanted to compare the prediction of the local model to the prediction of the underlying model for this point.
Unfortunately, the $predict() method throws an error if the input is a data.frame with only one row.
I use
library("randomForest")
library("iml")
set.seed(123L)
rf = randomForest(Species ~ ., data = iris)
mod = Predictor$new(rf, data = iris)
# Local model
x.interest = iris[1,]
x.interest$Species = NULL
locmod = LocalModel$new(mod, x.interest)
locmod$results
locmod$predict(x.interest)
# Error in names(x) <- value :
# 'names' attribute [3] must be the same length as the vector [1]
The error does not occur if the input is a data.frame with more than one row.
Hi, after I fitted a local surrogate model with
LocalModel
to explain the prediction of a point of interest, I wanted to compare the prediction of the local model to the prediction of the underlying model for this point. Unfortunately, the$predict()
method throws an error if the input is a data.frame with only one row. I useThe error does not occur if the input is a
data.frame
with more than one row.