I tried to use Shap (Tree Explainer) for sklearn.ensemble._stacking.StackingClassifier
explainer = shap.TreeExplainer(clf)
shap_values = explainer.shap_values(x)
shap.initjs()
return shap.force_plot(explainer.expected_value[1], shap_values[1], x)
But I got an error:
Model type not yet supported by TreeExplainer: <class 'sklearn.ensemble._stacking.StackingClassifier'>
How can I use shap force_plot for sklearn StackingClassifier?
Thank you.
TreeExplainer only works on tree-based models themselves, not on pipelines or metamodels that end with a tree-based model.
If you want interpretability in terms of your original features, you will need to use the base Explainer class (or equivalently, the KernelExplainer class). Unfortunately, this will be approximate and more computationally expensive.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With