Save SHAP summary plot as PDF/SVG - Stack Overflow
stackoverflow.com › questions › 52137579Sep 02, 2018 · import shap import matplotlib.pyplot as plt shap.initjs () explainer = shap.TreeExplainer (bst) shap_values = explainer.shap_values (train) fig = shap.summary_plot (shap_values, train, show=False) plt.savefig ('shap.png') However, I need PDF or SVG plots instead of png and therefore tried to save it with plt.savefig ('shap.pdf') which normally ...
shap/_beeswarm.py at master · slundberg/shap · GitHub
github.com › slundberg › shapassert len (shap_values. shape) != 1, "Summary plots need a matrix of shap_values, not a vector." # default color: if color is None: if plot_type == 'layered_violin': color = "coolwarm" elif multi_class: color = lambda i: colors. red_blue_circle (i / len (shap_values)) else: color = colors. blue_rgb: idx2cat = None # convert from a DataFrame or other types