如何解决如何将多个形状图保存到 html 中?
我使用 facebookPostImage
包绘制了机器学习结果。特别是我绘制了一个交互式形状力图和一个静态形状热图。
目前我将 shap 力图保存为 html 文件,但我想将 shap 热图添加到交互式力图下方的 html。
此处显示了交互式形状力图的示例:https://shap.readthedocs.io/en/latest/example_notebooks/tabular_examples/tree_based_models/Force%20Plot%20Colors.html(第三个图向下,交互式图)
形状热图的示例如下:https://shap.readthedocs.io/en/latest/example_notebooks/api_examples/plots/heatmap.html
我目前如何为这些图编码:
shap
目前将 import shap
model = RandomForestRegressor()
explainer = shap.TreeExplainer(model)
shap_values = explainer(X)
select = range(8)
features = X.iloc[select]
features_display = X.loc[features.index]
#Create force plot and save it as html:
output_of_force_plot = shap.force_plot(explainer.expected_value,shap_values[:500,:],X.iloc[:500,features_display,show=False)
file ='force_plot.html'
shap.save_html(file,output_of_force_plot)
#Create static heat map:
shap_heatmap = shap.plots.heatmap(shap_values,max_display=8,show=False)
添加到与 shap_heatmap
相同的 html 我已经尝试了类似问题的答案与 plotly (Plotly saving multiple plots into a single html) 但它不起作用:
output_of_force_plot
有什么方法可以修改此 import plotly
with open('p_graph.html','a') as f:
shap.save_html(file,output_of_force_plot,full_html=False)
f.write(shap_heatmap.to_html(full_html=False))
AttributeError: 'NoneType' object has no attribute 'to_html'
示例以适用于我的 shap html?或者我可以将我的 2 个数字组合成一个 html 的另一种方式?我只希望交互式绘图保持交互式,然后在交互式绘图下方显示形状热图。不幸的是,在这种情况下,我无法提供示例数据来制作精确的图。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。