Code used,
background = X_train
explainer = shap.DeepExplainer(yx_model, background)
data_for_prediction = X_test[1:2]
print( "Data for prediction: {}".format(data_for_prediction) )
shap_values = explainer.shap_values(data_for_prediction)
shap.force_plot(explainer.expected_value[0], shap_values[0], data_for_prediction)
Get this result,
Visualization omitted, Javascript library not loaded!
Have you run `initjs()` in this notebook? If this notebook was from another user you must also trust this notebook (File -> Trust notebook). If you are viewing this notebook on github the Javascript has been stripped for security. If you are using JupyterLab this error is because a JupyterLab extension has not yet been written.
How to solve?
Looks like Google Colab needs shap.initjs() in every cell where there is a visualization.
Thanks for the heads up!
Does it work with using shap.initjs() in every cell in Google Colab?
Does it work with using
shap.initjs()in every cell in Google Colab?
Yes, it does work
Most helpful comment
Looks like Google Colab needs
shap.initjs()in every cell where there is a visualization.