首页 > 解决方案 > Python Jupyter notebook SHAP force_plot,如何更改深色主题中的背景颜色或文本颜色?

问题描述

在此处输入图像描述

有什么方法可以更改深色主题中的绘图背景颜色或文本颜色?我需要白色背景或白色文本。

该图是 IPython.core.display.HTML 的一个对象。

它是由

shap.force_plot(explainer.expected_value[1], shap_values[1][0,:], X_test.iloc[0,:],link="logit")

谢谢您的帮助!

标签: pythonhtmlnode.jsjupyter-notebookshap

解决方案


加上 的参数后matplotlib=True,问题就解决了。

shap.force_plot(explainer.expected_value[1], shap_values[1][0,:], X_test.iloc[0,:],link="logit", matplotlib=True)

似乎该图是使用 matplotlib 在 html 文件上创建的。

为了正确绘图,首先我 style.use('seaborn-dark') 在 Jupyter notebook 的深色模型中使用。


推荐阅读