Closed dax44 closed 1 year ago
I've learned Keras sequential model with the following code:
library(keras) library(fastshap) x_train <- iris |> slice(1:100) |> select(-Species) |> as.matrix() y_train <- iris |> slice(1:100) |> select(Species) |> mutate(Species = as.numeric(Species)-1) |> as.matrix() mod <- keras_model_sequential() mod |> layer_dense(units = 16, input_shape = 4) |> layer_activation(activation = "relu") |> layer_dropout(rate = 0.3) |> layer_dense(units = 1, activation = "sigmoid") mod |> compile(optimizer = "nadam", loss = loss_binary_crossentropy()) history <- fit( object = mod, x = x_train, y = y_train, batch_size = 10, epochs = 30, validation_split = 0.1 )
Then I tried to build explainer with fastshap explainer
p_fun <- function(object, newdata) predict(object, x = newdata) shp_exp <- fastshap::explain(mod, X = x_train, pred_wrapper = p_fun) shp_exp
but my shp_exp has only one row... why?
Is this project died?
The predict function should return only one numeric value: https://github.com/bgreenwell/fastshap/issues/14
I've learned Keras sequential model with the following code:
Then I tried to build explainer with fastshap explainer
but my shp_exp has only one row... why?