【问题标题】:Python Jupyter notebook SHAP force_plot, how to change the background color or text color in the dark theme?Python Jupyter notebook SHAP force_plot,如何更改深色主题中的背景颜色或文本颜色?
【发布时间】:2020-02-15 12:42:57
【问题描述】:

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

绘图是 IPython.core.display.HTML 的对象。

它是由

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

感谢您的帮助!

【问题讨论】:

    标签: python html node.js jupyter-notebook shap


    【解决方案1】:

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

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

    似乎情节是在 html 文件上使用 matplotlib 创建的。

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

    【讨论】:

    • 这行得通(感谢风格提示!),但是:你会失去情节的互动性,不是吗?此外:"matplotlib = True is not yet supported for force plots with multiple samples!" - 这意味着您不能在一次检查多个预测时使用它...
    【解决方案2】:

    解决方法是将图形导出为 html 文件,然后在浏览器中打开:

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

    但我想浅色方案也可以规避这个问题?

    【讨论】:

      猜你喜欢
      • 2018-12-25
      • 1970-01-01
      • 2016-06-02
      • 1970-01-01
      • 1970-01-01
      • 2021-03-11
      • 1970-01-01
      • 2011-06-11
      • 1970-01-01
      相关资源
      最近更新 更多