Looking into the shap library, I came across this question, in which the answer showcased the waterfall plot, neat! Looking at some of the official examples here and here I notice the plots also showcase the value of the features.
The shap package contains both shap.waterfall_plot
and shap.plots.waterfall
, trying both on a Random Forest trained on the Iris dataset gave the same results (see one code and image example below)
for which_class in y.unique():
display(
shap.waterfall_plot(shap.Explanation(values=shap_values[int(which_class)][idx],
base_values=explainer.expected_value[int(which_class)],
feature_names=X_test.columns.tolist())
)
)
In which idx
indicates a sample in the test set I'm trying to explain. The code generates the following plot for one of the classes:
How can I get the plot to also display the feature values? I didn't see any additional arguments I could pass to the plot method
Any help is greatly appreciated!