Skip to content

Commit dcd7181

Browse files
committed
cleaned up a bit
1 parent 75ac403 commit dcd7181

10 files changed

Lines changed: 3568 additions & 25 deletions

File tree

README.md

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,63 @@
11

2-
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://pat-alt.github.io/CounterfactualExplanations.jl/stable) [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://pat-alt.github.io/CounterfactualExplanations.jl/dev) [![Build Status](https://github.com/pat-alt/CounterfactualExplanations.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/pat-alt/CounterfactualExplanations.jl/actions/workflows/CI.yml?query=branch%3Amain) [![Coverage](https://codecov.io/gh/pat-alt/CounterfactualExplanations.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/pat-alt/CounterfactualExplanations.jl) [![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle) [![ColPrac: Contributor’s Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor's%20Guide-blueviolet.png)](https://github.com/SciML/ColPrac) [![Twitter Badge](https://img.shields.io/twitter/url/https/twitter.com/paltmey.svg?style=social&label=Follow%20%40paltmey)](https://twitter.com/paltmey)
2+
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://pat-alt.github.io/AlgorithmicRecourseDynamics.jl/stable) [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://pat-alt.github.io/AlgorithmicRecourseDynamics.jl/dev) [![Build Status](https://github.com/pat-alt/AlgorithmicRecourseDynamics.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/pat-alt/AlgorithmicRecourseDynamics.jl/actions/workflows/CI.yml?query=branch%3Amain) [![Coverage](https://codecov.io/gh/pat-alt/AlgorithmicRecourseDynamics.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/pat-alt/AlgorithmicRecourseDynamics.jl) [![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle) [![ColPrac: Contributor’s Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor's%20Guide-blueviolet.png)](https://github.com/SciML/ColPrac) [![Twitter Badge](https://img.shields.io/twitter/url/https/twitter.com/paltmey.svg?style=social&label=Follow%20%40paltmey)](https://twitter.com/paltmey)
33

44
# AlgorithmicRecourseDynamics
55

6-
`AlgorithmicRecourseDynamics.jl` is a Julia package for modeling Algorithmic Recourse Dynamics.
6+
`AlgorithmicRecourseDynamics.jl` is a small package for modeling Algorithmic Recourse Dynamics. It builds on `CounterfactualExplanations`, a package for generating counterfactual explanations.
77

8-
## Related Research Paper 📝
8+
## Basic Usage
9+
10+
### Data and Model
11+
12+
``` julia
13+
N = 1000
14+
xmax = 2
15+
X, ys = make_blobs(
16+
N, 2;
17+
centers=2, as_table=false, center_box=(-xmax => xmax), cluster_std=0.1
18+
)
19+
ys .= ys.==2
20+
X = X'
21+
counterfactual_data = CounterfactualData(X,ys')
22+
```
23+
24+
``` julia
25+
n_epochs = 100
26+
model = Chain(Dense(2,1))
27+
mod = FluxModel(model)
28+
29+
generator = GenericGenerator()
30+
```
31+
32+
``` julia
33+
data_train, data_test = Data.train_test_split(counterfactual_data)
34+
Models.train(mod, data_train; n_epochs=n_epochs)
35+
plt_original = plot(mod, counterfactual_data; zoom=0, colorbar=false)
36+
display(plt_original)
37+
```
38+
39+
![](README_files/figure-commonmark/cell-5-output-1.svg)
940

10-
In this work we investigate what happens if Algorithmic Recourse is actually implemented by a large number of individuals. The chart below illustrates what we mean by Endogenous Macrodynamics in Algorithmic Recourse: (a) we have a simple linear classifier trained for binary classification where samples from the negative class (y=0) are marked in blue and samples of the positive class (y=1) are marked in orange; (b) the implementation of AR for a random subset of individuals leads to a noticable domain shift; (c) as the classifier is retrained we observe a corresponding model shift; (d) as this process is repeated, the decision boundary moves away from the target class.
41+
### Simulation
42+
43+
``` julia
44+
models = Dict(:mymodel => mod)
45+
generators = Dict(:wachter => generator)
46+
experiment = set_up_experiment(data_train, data_test, models, generators)
47+
```
48+
49+
``` julia
50+
run!(experiment)
51+
```
52+
53+
``` julia
54+
new_data = experiment.recourse_systems[1][1].data
55+
new_model = experiment.recourse_systems[1][1].model
56+
plt_original = plot(new_model, new_data; zoom=0, colorbar=false)
57+
```
58+
59+
![](README_files/figure-commonmark/cell-8-output-1.svg)
60+
61+
## Related Research Paper 📝
1162

12-
![](paper/www/poc.png)
63+
The package was developed for a research project that investigates the dynamics of various counterfactual generators.

README.qmd

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ bibliography: bib.bib
1515
jupyter: julia-1.8
1616
---
1717

18-
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://pat-alt.github.io/CounterfactualExplanations.jl/stable)
19-
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://pat-alt.github.io/CounterfactualExplanations.jl/dev)
20-
[![Build Status](https://github.com/pat-alt/CounterfactualExplanations.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/pat-alt/CounterfactualExplanations.jl/actions/workflows/CI.yml?query=branch%3Amain)
21-
[![Coverage](https://codecov.io/gh/pat-alt/CounterfactualExplanations.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/pat-alt/CounterfactualExplanations.jl)
22-
[![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle)
23-
[![ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor's%20Guide-blueviolet)](https://github.com/SciML/ColPrac)
18+
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://pat-alt.github.io/AlgorithmicRecourseDynamics.jl/stable)
19+
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://pat-alt.github.io/AlgorithmicRecourseDynamics.jl/dev)
20+
[![Build Status](https://github.com/pat-alt/AlgorithmicRecourseDynamics.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/pat-alt/AlgorithmicRecourseDynamics.jl/actions/workflows/CI.yml?query=branch%3Amain)
21+
[![Coverage](https://codecov.io/gh/pat-alt/AlgorithmicRecourseDynamics.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/pat-alt/AlgorithmicRecourseDynamics.jl)
22+
[![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle)
23+
[![ColPrac: Contributors Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor's%20Guide-blueviolet.png)](https://github.com/SciML/ColPrac)
2424
[![Twitter Badge](https://img.shields.io/twitter/url/https/twitter.com/paltmey.svg?style=social&label=Follow%20%40paltmey)](https://twitter.com/paltmey)
2525

2626
# AlgorithmicRecourseDynamics

0 commit comments

Comments
 (0)