我无法在Azure笔记本中运行shap.initjs()。放弃在Azure社区论坛或其他地方查阅这个问题。

shap.initjs()
test_sample = test_x.iloc[:2000,:]
shap_values_sample = explainer.shap_values(test_sample)
shap.force_plot(explainer.expected_value[1], shap_values_sample[1], test_sample, link="logit")发布于 2022-03-01 07:00:21
我为Databricks找到了一个解决方案。您只需将HTML从force_plot中取出,并使用displayHTML查看force_plot。试试这个:
force_plot = shap.force_plot(xgb_explainer.expected_value, xgb_shap_values, X_test, matplotlib=False)
shap_html = f"<head>{shap.getjs()}</head><body>{force_plot.html()}</body>"
displayHTML(shap_html)更多信息:https://towardsdatascience.com/tutorial-on-displaying-shap-force-plots-in-python-html-4883aeb0ee7c
https://stackoverflow.com/questions/69383672
复制相似问题