On devel branch using a glm model gives an error due to being of class glm and lm.
library(data.table)
library(shapr)
# Data
n = 100
beta = c(-0.5, 0.5)
x_train = data.table(matrix(rnorm(n*2), ncol = 2))
dt = data.table(y=y, x_train)
x_test = x_train[1:10, ]
y = rpois(n, exp(as.matrix(x_train) %*% beta))
p = mean(y)
# Model
model = glm(y ~ ., data = dt, family = poisson)
explanation <- explain(
x_train,
x_test,
model = model,
approach = "empirical",
prediction_zero = p,
)
Gives the error message
Error in get(paste0("get_model_specs.", model_class0)) :
first argument has length > 1
In addition: Warning message:
In if (native_func_available) { :
the condition has length > 1 and only the first element will be used
On devel branch using a glm model gives an error due to being of class
glm
andlm
.Gives the error message
which comes from this line in
get_feature_specs
:https://github.com/NorskRegnesentral/shapr/blob/f3081da8ec0436489b373f122d00dce7d907c426/R/model_setup_R.R#L27
as a
glm
model is of classlm
andglm
.This will happen with GAMs as well, because they are in addition of class
gam
.