如何更改shap summary图表上的坐标轴

3
我正在按照此链接中的代码进行操作,只是稍微用了不同的数值(所以我的代码与链接中描述的完全相同)。
我的输出结果如下所示:

enter image description here

请问有人能够向我展示如何更改X轴(理想情况下自动更改,因为我需要为不同的数据集制作多个图表),以便数据分散,整个图表都能看到吗?
1个回答

5

参考问题中给出的代码链接,在计算完 shap_values 后,你可以尝试以下解决方案:

import matplotlib.pyplot as plt 
.
.
# Calculate shap_values
fig = shap.summary_plot(shap_values[1], X_test, show=False)
_, h = plt.gcf().get_size_inches()
plt.gcf().set_size_inches(h*5, h)
plt.show()

或者

import matplotlib.pyplot as plt 
.
.
# Calculate shap_values
shap.summary_plot(shap_values[1], X_test, show=False)
ax = plt.gca()

# You can change the min and max value of xaxis by changing the arguments of:
ax.set_xlim(-0.5, 0.5) 
plt.show()

您还可以结合上述解决方案,以获得最佳的结果分辨率。
请参考此答案获取更多信息。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接