Skip to content

Commit

Permalink
chore(shap): sample background dataset to make explanation faster
Browse files Browse the repository at this point in the history
  • Loading branch information
ireneisdoomed committed Feb 20, 2025
1 parent 2f86159 commit ade23c5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/gentropy/dataset/l2g_prediction.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,11 @@ def _explain(
raise AttributeError(
"`model.training_data` is missing, seed dataset to get shapley values cannot be created."
)
background_data = model.training_data._df.select(
*model.features_list
).toPandas()
background_data = (
model.training_data._df.select(*model.features_list)
.toPandas()
.sample(n=1_000)
)
explainer = shap.TreeExplainer(
model.model,
data=background_data,
Expand Down

0 comments on commit ade23c5

Please sign in to comment.