py-why / py-why/EconML

Bug with SHAP library v.0.41

Open
#806 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Jupyter Notebook
Stars
4.8k
Forks
827
PR merge metrics
No merged PRs in 30d

Description

This bug was present in some SHAP plots (such as in the bar plots):

shap.plots.bar(shap_values_game)

---------------------------------------------------------------------------
UnboundLocalError                         Traceback (most recent call last)
Cell In[47], line 1
----> 1 shap.plots.bar(shap_values_game)

File ~/anaconda3/envs/shap_env2/lib/python3.9/site-packages/shap/plots/_bar.py:54, in bar(shap_values, max_display, order, clustering, clustering_cutoff, merge_cohorts, show_data, show)
     51     assert isinstance(shap_values, dict), "You must pass an Explanation object, Cohorts object, or dictionary to bar plot!"
     53 # unpack our list of Explanation objects we need to plot
---> 54 cohort_labels = list(cohorts.keys())
     55 cohort_exps = list(cohorts.values())
     56 for i in range(len(cohort_exps)):

UnboundLocalError: local variable 'cohorts' referenced before assignment

This bug was fixed in the 0.42 release (https://github.com/shap/shap/releases/tag/v0.42.0); however, econml has SHAP<=0.41 as a requirement, so these issues will persist until the requirements for the SHAP version are updated.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review EconML's SHAP<=0.41 requirement and the SHAP v0.42.0 release linked in the issue, then locate where the dependency constraint is defined. Update the supported SHAP version and verify that the affected SHAP plots no longer encounter the reported error.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter-notebook, python
Domain
machine-learning
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.