Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: UnboundLocalError with bar plots using dictionary input #3001

Merged
merged 4 commits into from
Jun 19, 2023

Conversation

thatlittleboy
Copy link
Collaborator

Overview

Description of the changes proposed in this pull request:

  • Fixes the UnboundLocalError by assigning the cohorts variable when the input is a dictionary (previously, only an assertion was checked with no binding of the cohorts variable).
  • Added a test for ensuring that dictionary input to shap.plots.bar works as expected (just a basic plot).
  • Added some additional tests to ensure the input type to shap.plots.bar is either an Explanation, a Cohorts, or a dictionary of Explanation objects with the same number of feature columns in each Explanation object.

Checklist

@codecov
Copy link

codecov bot commented Jun 17, 2023

Codecov Report

Merging #3001 (743fe68) into master (29940b4) will increase coverage by 0.05%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #3001      +/-   ##
==========================================
+ Coverage   54.73%   54.79%   +0.05%     
==========================================
  Files          90       90              
  Lines       12887    12895       +8     
==========================================
+ Hits         7054     7066      +12     
+ Misses       5833     5829       -4     
Impacted Files Coverage Δ
shap/plots/_bar.py 59.54% <100.00%> (+3.41%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Collaborator

@connortann connortann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice one!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: shap.plots.bar with cohorts dict throws UnboundLocalError
2 participants