Skip to content

Commit

Permalink
Merge branch 'main' into fix_auth_ci_test
Browse files Browse the repository at this point in the history
  • Loading branch information
YuanTingHsieh authored Nov 27, 2024
2 parents ca4cbfc + 60d292e commit 5610731
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
2 changes: 2 additions & 0 deletions examples/advanced/xgboost/histogram-based/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ pandas
scikit-learn
torch
tensorboard
matplotlib
shap
# require xgboost 2.2 version, for now need to install a nightly build
https://s3-us-west-2.amazonaws.com/xgboost-nightly-builds/federated-secure/xgboost-2.2.0.dev0%2B4601688195708f7c31fcceeb0e0ac735e7311e61-py3-none-manylinux_2_28_x86_64.whl
2 changes: 2 additions & 0 deletions examples/advanced/xgboost/tree-based/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ pandas
scikit-learn
torch
tensorboard
matplotlib
shap
# require xgboost 2.2 version, for now need to install a nightly build
https://s3-us-west-2.amazonaws.com/xgboost-nightly-builds/federated-secure/xgboost-2.2.0.dev0%2B4601688195708f7c31fcceeb0e0ac735e7311e61-py3-none-manylinux_2_28_x86_64.whl
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,16 @@ def run(self, ctx: dict):
bst.save_model(os.path.join(self._model_dir, self.model_file_name))
xgb.collective.communicator_print("Finished training\n")

# Save explanability outputs based on val_data
explainer = shap.TreeExplainer(bst)
explanation = explainer(val_data)

# save the beeswarm plot to png file
shap.plots.beeswarm(explanation, show=False)
img = plt.gcf()
img.subplots_adjust(left=0.3, right=0.9, bottom=0.3, top=0.9)
img.savefig(os.path.join(self._model_dir, "shap_beeswarm.png"), bbox_inches="tight")
if self._data_split_mode == 0:
# Save explainability outputs based on val_data
explainer = shap.TreeExplainer(bst)
explanation = explainer(val_data)

# save the beeswarm plot to png file
shap.plots.beeswarm(explanation, show=False)
img = plt.gcf()
img.subplots_adjust(left=0.3, right=0.9, bottom=0.3, top=0.9)
img.savefig(os.path.join(self._model_dir, "shap_beeswarm.png"), bbox_inches="tight")

self._stopped = True

Expand Down

0 comments on commit 5610731

Please sign in to comment.