Azure Data Studio 中的形状渲染

Pat*_*bos 1 javascript azure-data-studio shap

我无法在 Azure Data Studio Notebook 中运行 shap.initjs()。放弃在 Azure 社区论坛或其他地方查找问题。

可视化被省略,Javascript 库未加载!

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")
Run Code Online (Sandbox Code Playgroud)

Ama*_*ngh 5

我得到了 Databricks 的解决方案。您只需从force_plot 中获取HTML 并使用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)
Run Code Online (Sandbox Code Playgroud)

更多信息:https://towardsdatascience.com/tutorial-on-displaying-shap-force-plots-in-python-html-4883aeb0ee7c