在SHAP力图中,有没有办法将x轴的值更改为自定义名称?

问题描述 投票:0回答:2

在SHAP力图中,有没有办法将x轴的值更改为自定义名称?

f = plt.figure(figsize=(8, 6))
shap.summary_plot(shap_values, X_test, plot_type="bar", feature_names=X_train.columns, class_names = ORGD_Test['Class']) 
python shap lime
2个回答
0
投票
shap.summary_plot(shap_values, show=False)

# Get the current figure and axes objects.
fig, ax = plt.gcf(), plt.gca()

# Set the limits for the x-axis and similarly can be done for the y-axis also
ax.set_xlim(-60, 125)
ax.set_xlim(-60, 125)
ax.set_title(ax_title, fontdict={"size":font_size})

0
投票

如果您想更改功能字体大小,此代码对我有用:

shap.summary_plot(shap_values, show=False)

获取当前图形和轴对象。

图, ax = plt.gcf(), plt.gca()

对于 ax.texts 中的文本: text.set_fontsize( your_font_size_number)

plt.show()

© www.soinside.com 2019 - 2024. All rights reserved.