Issue
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.
Solution
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.
Answered By - eschibli
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.