Skip to content

Commit f7982ef

Browse files
committed
hide shap warning (#795)
1 parent ee6dd9f commit f7982ef

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

supervised/utils/shap.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,14 @@ def summary(shap_values, X_vald, model_file_path, learner_name, class_names):
119119
classes = None
120120
if class_names is not None and len(class_names):
121121
classes = class_names
122-
123-
shap.summary_plot(
124-
shap_values, X_vald, plot_type="bar", show=False, class_names=classes
125-
)
126-
fig.tight_layout(pad=2.0)
127-
fig.savefig(os.path.join(model_file_path, f"{learner_name}_shap_summary.png"))
128-
plt.close("all")
122+
with warnings.catch_warnings():
123+
warnings.simplefilter("ignore")
124+
shap.summary_plot(
125+
shap_values, X_vald, plot_type="bar", show=False, class_names=classes
126+
)
127+
fig.tight_layout(pad=2.0)
128+
fig.savefig(os.path.join(model_file_path, f"{learner_name}_shap_summary.png"))
129+
plt.close("all")
129130

130131
vals = None
131132
if isinstance(shap_values, list):

0 commit comments

Comments
 (0)