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

Implement CounterPlots to DiCE CF generation #377

Closed
wants to merge 3 commits into from
Closed

Implement CounterPlots to DiCE CF generation #377

wants to merge 3 commits into from

Conversation

rmazzine
Copy link
Contributor

Dear DiCE developing team,

This PR adds to DiCE a novel way to represent counterfactual explanations. The current DiCE only shows the explanations as a list of parameters, and we know the importance of having more graphically appealing representations, especially when creating explanations.

Therefore, we've developed a new package to generate metrics and charts that augment the informative value of counterfactual explanations, CounterPlots (https://github.com/ADMAntwerp/CounterPlots), the preprint article with full information can be found in this link: https://arxiv.org/abs/2306.06506

I also have made a Medium blog post with a more summarized review of the methods: https://mazzine.medium.com/measuring-counterfactual-explanations-feature-importance-with-counterplots-41359bc85aea

We hope this new package can be useful to you and we are open for your comments and suggestions, below I made a more technical description of the changes made in this PR.

This commit adds the CounterPlots package to the DiCE CF generation package. Basically, the CounterfactualExplanations object was changed to now include a new method generate_counterplots which takes factual, counterfactual, and DataFrame info to generate the counterfactual analysis. Also, this object now asks for a prediction function, therefore, the explainer_base, dice_tensorflow1, and dice_tensorflow2 now include this function to create the object.

Best wishes,

This commit adds the CounterPlots package to the DiCE CF generation package. Basically, the `CounterfactualExplanations` object was changed to now include a new method `generate_counterplots` which takes factual, counterfactual, and DataFrame info to generate the counterfactual analysis. Also, this object now asks for a prediction function, therefore, the `explainer_base`, `dice_tensorflow1`, and `dice_tensorflow2` now include this function to create the object.
@rmazzine
Copy link
Contributor Author

dice_counterplots_example_notebook.zip

The zip above has a Jupyter Notebook that shows how counterplots work with DiCE.

@rmazzine
Copy link
Contributor Author

Very soon I will make the necessary modifications in the unitary tests.

@codecov-commenter
Copy link

Codecov Report

Patch coverage: 24.24% and project coverage change: -1.51 ⚠️

Comparison is base (b1b21ae) 68.33% compared to head (bbf511d) 66.83%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #377      +/-   ##
==========================================
- Coverage   68.33%   66.83%   -1.51%     
==========================================
  Files          27       27              
  Lines        3610     3639      +29     
==========================================
- Hits         2467     2432      -35     
- Misses       1143     1207      +64     
Flag Coverage Δ
unittests 66.83% <24.24%> (-1.51%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
dice_ml/explainer_interfaces/dice_tensorflow1.py 0.00% <0.00%> (ø)
dice_ml/counterfactual_explanations.py 65.42% <20.00%> (-30.81%) ⬇️
dice_ml/explainer_interfaces/dice_tensorflow2.py 85.06% <100.00%> (ø)
dice_ml/explainer_interfaces/explainer_base.py 88.11% <100.00%> (-0.26%) ⬇️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@amit-sharma
Copy link
Collaborator

@rmazzine Thanks for starting this PR. Will you be able to look at the unit tests and make sure that they pass?

Apologies that I missed responding to this earlier.

Signed-off-by: Raphael Mazzine, PhD <43969088+rmazzine@users.noreply.github.com>
@rmazzine
Copy link
Contributor Author

I will close this PR because I've made a better (and easier) solution in PR #402

@rmazzine rmazzine closed this Sep 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants