dandls / counterfactuals

counterfactuals: An R package for Counterfactual Explanation Methods
https://dandls.github.io/counterfactuals/
GNU Lesser General Public License v3.0
21 stars 4 forks source link

Problem with WhatIfClassif counterfactual generation #7

Closed RifatMehreen closed 2 years ago

RifatMehreen commented 2 years ago

@andreash0, @susanne-207 I had been working on COMPAS dataset for recidivism. The generated counterfactuals are weirdly the same. I am attaching the screenshots here:

Code snippets: You can see that generated 5 counterfactuals are exactly the same: recidivism_1 recidivism_2

Plot: Rplot_whatif

andreash0 commented 2 years ago

WhatIf returns the k closest data points of x_interest as counterfactuals. Could it be that the data point that is returned as counterfactual exists multiple times in your dataset?

RifatMehreen commented 2 years ago

I checked the dataset and it seems that there are lots of duplicates in the dataset. I removed them and now the results are alright. Thanks.

andreash0 commented 2 years ago

Great!

@susanne-207: Should we restrict the WhatIf counterfactual search space to unique observations?

X_search = unique(X_search)
dandls commented 2 years ago

A bit late, but yes :)