Getting error from "explain" function

I am trying to find SHAPs of a random forest model! I am using the "explain" function and this is the code:

  exp_forest <- fastshap::explain(my_model,X = subset(train_data, select = -training_target),pred_wrapper= predict,nsim = 1)

But I get this error:
no applicable method for 'predict' applied to an object of class "randomForest" Calls: ... lapply -> FUN -> explain_column -> pred_wrapper -> predict Execution halted

Any Idea?
Thanks in advance

In general if you cant run a simple predict on your model, you likely havent loaded the R library that implements the model and supporting features. In this case randomForest

1 Like

Thanks, it worked!
Do you know the above command for an MLP model? A model which is made by this function:
Actually, I couldn't find any function to give me the SHAP of those types of models.

what's your issue with such a model ? I would expect that they should provide something equivalent to a predict method that could be used as a pred_wrapper ...

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.