Search code examples
pythonshap

How do i get my SHAP plot to display more than 20 variables?


How do i get my SHAP plot to display more than 20 variables in my chart. Here is my code:

shap.initjs()
explainer = shap.TreeExplainer(model)
shap_values = explainer.shap_values(X_train)

shap.summary_plot(shap_values, X_train)
plt.savefig(Config.CLASH_PATH + '/plots/shap_' + target_cols + '.png')
plt.close()

SHAP graph


Solution

  • Use option max_display=30 in shap.summary_plot().