-2

code:

import shap
from pycaret.classification import load_model,  predict_model 

pipe = load_model(<my_loaded_model>)
dataframe = <My Dataframe>
explainer = shap.TreeExplainer(pipe.named_steps['trained_model'])
train_full_pipe = pipe[:-1].transform(dataframe)

In the last line train_full_pipe = pipe[:-1].transform(dataframe) I get error.

It worked before, I upload new models, and now I am getting this error for any new models.

desertnaut
  • 57,590
  • 26
  • 140
  • 166
Sc0der
  • 1
  • 1
  • 1
  • What new model did you load? `shap.TreeExplainer` is for ensemble tree models. If you are tyring to load neural networks, try `shap.DeepExplainer` or `shap.KernelExplainer` – Musabbir Arrafi Aug 29 '23 at 09:09
  • 1
    If it's getting stuck on `train_full_pipe = pipe[:-1].transform(dataframe)` that's not a shap erorr, that's (I'm assuming) a scikit-learn model (specifically the pipeline up to but not including the actual estimator). I suspect your issue lies with the model or the dataset and not shap – David Waterworth Aug 29 '23 at 09:09

0 Answers0