I am working on binary classification and trying to explain my model using SHAP framework.
I am using logistic regression algorithm. I would like to explain this model using both KernelExplainer
and LinearExplainer
.
So, I tried the below code from SO
Note: KernelExplainer
doesn't support maskers, and in this case either loc
or iloc
will return the same.
background = Independent(X, max_samples=100)
explainer = LinearExplainer(model,background)
sv = explainer(X.loc[[5]]) # pass the row of interest by index
waterfall(sv[0])
Note here, LinearExplainer
's result can be provided to waterfall "as-is"