|
2 | 2 |
|
3 | 3 | ## Endogenous Macrodynamics |
4 | 4 |
|
5 | | -## Potential Mitigation Strategies |
6 | 5 |
|
7 | | -### Gravitational Counterfactual Explanations {#sec-empirical-2-mitigate} |
8 | 6 |
|
9 | | -A straight-forward choice simply extends the baseline approach by @wachter2017counterfactual: instead of only penalizing the distance of the individuals' counterfactual to its factual, we propose penalizing its distance to some sensible point in the target domain, for example the sample average: $\bar{\mathbf{x}}$. For such a recourse objective, higher choices of $\lambda_2$ relative to $\lambda_1$ will lead counterfactuals to gravitate towards the specified point in the target domain. In the remainder of this paper we will therefore refer to this approach as **Gravitational** generator, when we investigate its potential usefulness for mitigating endongenous macrodynamics^[Note that despite the naming convention our goal here is not to provide yet another counterfactual generator, but merely investigate the most simple penalty we can think of with respect to its effectiveness.]. |
| 7 | +## Potential Mitigation Strategies {#sec-empirical-2-mitigate} |
10 | 8 |
|
11 | | -#### A note on convergence |
| 9 | +In the following we explore several ideas for strategies that may help to mitigate those types of endogenous recourse dynamics we observed in the previous subsection. All of them essentially boil down to one simple principle: to avoid substantial domain and model shifts, the generated counterfactuals should comply as much as possible with the true data generating process. This principle is really at the core of Latent Space generators, and hence it is not surprising that we have found these types of generators to perform comparably well in the previous subsection. But as we have mentioned earlier, generators that rely on separate generative models carry an additional computational cost and - perhaps more importantly - their performance hinges on the performance of said generative models. Fortunately, it turns out that we can use a number of other, much simpler strategies, which we will discuss now. |
12 | 10 |
|
13 | | -For this simple mitigating strategy underlying the Gravitational generator to work as expected, one needs to ensure that counterfactual search continues, even after a predetermined threshold probability $\gamma$ has potentially already been reached. @fig-convergence illustrates this distinction: if one chooses to terminate search once the desired threshold is reached (left panel) the gravitational pull towards $\bar{\mathbf{x}}$ is never actually satisfied (compare to right panel). More generally, if convergence is defined simply in terms of flipping the predicted label with some desired degree of confidence, this corresponds to essentially ignoring any parts of the counterfactual search objective that do not involve $\ell(M(f(s_k^\prime)),t)$ beyond that point. While this may be appropriate for some applications, in general this seems like an odd convention. Since we nonetheless seen convergence specified simply in terms of reaching the threshold probability in some places^[@joshi2019towards define convergence of Algorithm 1 in this way. The implementation of @wachter2017counterfactual in CARLA is also defined in this way.], we thought it worth making this distinction explicit. |
| 11 | +### More Conservative Decision Thresholds |
14 | 12 |
|
15 | | -{#fig-convergence fig.pos="h" width=45%} |
| 13 | +The most obvious and trivial mitigation strategy is to simply choose a higher decision threshold $\gamma$. Under $\gamma=0.5$, counterfactuals will end up near the decision boundary by construction. Since this is the region of maximal aleotoric uncertainty, the classifier is bound to be thrown off. By simply setting a more conservative decision threshold, we can avoid this issue to some extent. A potential drawback of this approach is that a classifier with high decisiveness may classify samples with high confidence even far away from the training data. |
| 14 | + |
| 15 | +### Classifier Preserving ROAR |
| 16 | + |
| 17 | +Another potential strategy draws inspiration from ROAR @upadhyay2021towards: to preserve the classifier, we propose to simply explicitly penalize the loss it incurs when evaluated on the counterfactual $x^\prime$ at given parameter values. Recall that $g(\cdot)$ denotes what we had defined as the external cost in @eq-collective. Then formally we let |
| 18 | + |
| 19 | +$$ |
| 20 | +\begin{aligned} |
| 21 | +g(f(s_k^\prime)) = l(M(f(s_k^\prime)),y^\prime) |
| 22 | +\end{aligned} |
| 23 | +$$ {#eq-clap} |
| 24 | +
|
| 25 | +for each counterfactual $k$ where $l$ denotes the loss function used to train $M$. This approach, which we shall refer to as **ClapROAR**, is based on the intuition that (endogenous) model shifts will be triggered by counterfactuals that increase classifier loss. It is closely linked to the idea of choosing higher decision threshold, but likely better at avoiding the potential pitfalls associated with highly decisive classifiers. It also makes the private vs. external cost trade-off more explicit and hence manageable. |
| 26 | +
|
| 27 | +### Gravitational Counterfactual Explanations |
| 28 | +
|
| 29 | +Yet another strategy simply extends Wachter as follows: instead of only penalizing the distance of the individuals' counterfactual to its factual, we propose penalizing its distance to some sensible point in the target domain, for example the sample average: $\bar{x}$: |
| 30 | +
|
| 31 | +$$ |
| 32 | +\begin{aligned} |
| 33 | +g(f(s_k^\prime)) = \text{dist}(f(s_k^\prime),\bar{x}) |
| 34 | +\end{aligned} |
| 35 | +$$ {#eq-clap} |
| 36 | +
|
| 37 | +Once again we can putting this in the context of @eq-collective, the former penalty can be thought of here as the private cost incurred by the individual, while the latter reflects the external cost incurred by other individuals. Higher choices of $\lambda_2$ relative to $\lambda_1$ will lead counterfactuals to gravitate towards the specified point $\bar{x}$ in the target domain. In the remainder of this paper we will therefore refer to this approach as **Gravitational** generator, when we investigate its potential usefulness for mitigating endongenous macrodynamics^[Note that despite the naming convention our goal here is not to provide yet another counterfactual generator, but merely investigate the most simple penalty we can think of with respect to its effectiveness.]. |
| 38 | +
|
| 39 | +@fig-mitigation shows an illustrative example that demonstrates the differences in counterfactual outcomes when using the various mitigation strategies compared to the baseline approach, that is Wachter with $\gamma=0.5$: choosing a higher decision threshold pushes the counterfactual a little further into the target domain; this effect is even stronger for ClapROAR; finally, using the Gravitational generator the counterfactual ends up all the way inside the target domain in the neighbourhood of $\bar{x}$^[In order for the Graviational generator and ClapROAR to work as expected, one needs to ensure that counterfactual search continues, independent of the threshold probability $\gamma$.]. |
| 40 | +
|
| 41 | +```{julia} |
| 42 | +#| eval: false |
| 43 | +using Random |
| 44 | +Random.seed!(2022) |
| 45 | +
|
| 46 | +# Data: |
| 47 | +using MLJ |
| 48 | +N = 1000 |
| 49 | +X, ys = make_blobs(N, 2; centers=2, as_table=false, center_box=(-5 => 5), cluster_std=0.5) |
| 50 | +ys .= ys.==2 |
| 51 | +X = X' |
| 52 | +xs = Flux.unstack(X,2) |
| 53 | +data = zip(xs,ys) |
| 54 | +counterfactual_data = CounterfactualData(X,ys') |
| 55 | +
|
| 56 | +# Models: |
| 57 | +using AlgorithmicRecourseDynamics |
| 58 | +M = AlgorithmicRecourseDynamics.Models.FluxModel(counterfactual_data) |
| 59 | +M = AlgorithmicRecourseDynamics.Models.train(M, counterfactual_data) |
| 60 | +
|
| 61 | +# Generators: |
| 62 | +generators = Dict( |
| 63 | + "Generic (γ=0.5)" => GenericGenerator(decision_threshold=0.5), |
| 64 | + "Generic (γ=0.9)" => GenericGenerator(decision_threshold=0.9), |
| 65 | + "Gravitational" => GravitationalGenerator(), |
| 66 | + "ClapROAR" => ClapROARGenerator() |
| 67 | +) |
| 68 | +
|
| 69 | +# Counterfactuals |
| 70 | +x = select_factual(counterfactual_data, rand(1:size(X)[2])) |
| 71 | +y = round(probs(M, x)[1]) |
| 72 | +target = ifelse(y==1.0,0.0,1.0) # opposite label as target |
| 73 | +T = 50 |
| 74 | +counterfactuals = Dict([name => generate_counterfactual(x, target, counterfactual_data, M, gen; T=T, latent_space=false) for (name, gen) in generators]) |
| 75 | +
|
| 76 | +# Plots: |
| 77 | +plts = [] |
| 78 | +for (name,ce) ∈ counterfactuals |
| 79 | + plt = plot(ce; title=name, colorbar=false, ticks = false, legend=false) |
| 80 | + plts = vcat(plts..., plt) |
| 81 | +end |
| 82 | +plt = plot(plts..., size=(750,200), layout=(1,4)) |
| 83 | +savefig(plt, "dev/paper/www/mitigation.png") |
| 84 | +``` |
| 85 | +
|
| 86 | +{#fig-mitigation fig.pos="h" width=45%} |
| 87 | +
|
| 88 | +Our findings ... |
0 commit comments