Skip to content

Commit

Permalink
Merge pull request #504 from JuliaTrustworthyAI/update-deps
Browse files Browse the repository at this point in the history
Updating Flux and EnergySamplers
  • Loading branch information
pat-alt authored Dec 31, 2024
2 parents ee300c4 + 997b0b3 commit 3961fd4
Show file tree
Hide file tree
Showing 18 changed files with 1,366 additions and 704 deletions.
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),

*Note*: We try to adhere to these practices as of version [v1.1.1].

## Version [1.4.0]
## Version [1.4.1] - 2024-12-19

### Changed

- Updated dependencies. [#504]

### Removed

- Removed everything related to GrowingSpheres. [#504]

## Version [1.4.0] - 2024-12-19

### Added

Expand Down
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "CounterfactualExplanations"
uuid = "2f13d31b-18db-44c1-bc43-ebaf2cff0be0"
authors = ["Patrick Altmeyer <[email protected]> and contributors"]
version = "1.4.0"
version = "1.4.1"

[deps]
CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"
Expand Down Expand Up @@ -44,13 +44,13 @@ NeuroTreeExt = "NeuroTreeModels"
[compat]
Aqua = "0.8"
CategoricalArrays = "0.10"
CausalInference = "0.17.0"
CausalInference = "0.17, 0.18"
ChainRulesCore = "1.15"
DataFrames = "1"
DecisionTree = "0.12.3, 0.12.4"
Distributions = "0.25.97"
EnergySamplers = "1.0"
Flux = "0.12, 0.13, 0.14"
Flux = "0.12, 0.13, 0.14, 0.15, 0.16"
Graphs = "1.11.1"
JointEnergyModels = "0.1.7"
LaplaceRedux = "0.1.4, 0.2, 1.0"
Expand Down
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ ce = generate_counterfactual(
plot(ce)
```

![](README_files/figure-commonmark/cell-3-output-1.svg)
[ Info: No target label supplied, using first.

![](README_files/figure-commonmark/cell-3-output-2.svg)

### Example: Give Me Some Credit

Expand Down Expand Up @@ -148,7 +150,7 @@ To this end, we specify a counterfactual generator of our choice:
generator = DiCEGenerator=[0.1,0.3])
```

Here, we have chosen to use the `GradientBasedGenerator` to move the individual from its factual label 1 to the target label 2.
Here, we have chosen to use the `CounterfactualExplanations.Generators.GradientBasedGenerator` to move the individual from its factual label 1 to the target label 2.

With all of our ingredients specified, we finally generate counterfactuals using a simple API call:

Expand All @@ -162,7 +164,9 @@ ce = generate_counterfactual(

The plot below shows the resulting counterfactual path:

![](README_files/figure-commonmark/cell-16-output-1.svg)
[ Info: No target label supplied, using first.

![](README_files/figure-commonmark/cell-16-output-2.svg)

## ☑️ Implemented Counterfactual Generators

Expand All @@ -176,7 +180,6 @@ Currently, the following counterfactual generators are implemented:
- Generic
- GravitationalGenerator (Altmeyer et al. 2023)
- Greedy (Schut et al. 2021)
- GrowingSpheres (Laugel et al. 2017)
- MINT (Karimi et al. 2020) (**causal CE**)
- PROBE (Pawelczyk et al. 2023)
- REVISE (Joshi et al. 2019)
Expand Down Expand Up @@ -251,8 +254,6 @@ Kaggle. 2011. “Give Me Some Credit, Improve on the State of the Art in Credit

Karimi, Amir-Hossein, Julius Von Kügelgen, Bernhard Schölkopf, and Isabel Valera. 2020. “Algorithmic Recourse Under Imperfect Causal Knowledge: A Probabilistic Approach.” <https://arxiv.org/abs/2006.06831>.

Laugel, Thibault, Marie-Jeanne Lesot, Christophe Marsala, Xavier Renard, and Marcin Detyniecki. 2017. “Inverse Classification for Comparison-Based Interpretability in Machine Learning.” <https://arxiv.org/abs/1712.08443>.

Mothilal, Ramaravind K, Amit Sharma, and Chenhao Tan. 2020. “Explaining Machine Learning Classifiers Through Diverse Counterfactual Explanations.” In *Proceedings of the 2020 Conference on Fairness, Accountability, and Transparency*, 607–17. <https://doi.org/10.1145/3351095.3372850>.

Pawelczyk, Martin, Teresa Datta, Johannes van-den-Heuvel, Gjergji Kasneci, and Himabindu Lakkaraju. 2023. “Probabilistically Robust Recourse: Navigating the Trade-Offs Between Costs and Robustness in Algorithmic Recourse.” <https://arxiv.org/abs/2203.06768>.
Expand Down
4 changes: 3 additions & 1 deletion README.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ crossref:
tbl-prefix: Table
bibliography: https://raw.githubusercontent.com/pat-alt/bib/main/bib.bib
output: asis
jupyter: julia-1.10
engine: julia
julia:
exeflags: ["--project=docs/"]
execute:
freeze: auto
eval: true
Expand Down
457 changes: 229 additions & 228 deletions README_files/figure-commonmark/cell-11-output-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
657 changes: 657 additions & 0 deletions README_files/figure-commonmark/cell-16-output-2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
361 changes: 361 additions & 0 deletions README_files/figure-commonmark/cell-3-output-2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
168 changes: 83 additions & 85 deletions README_files/figure-commonmark/cell-6-output-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/setup_docs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ setup_docs = quote

# Setup:
theme(:wong)
Random.seed!(2022)
Random.seed!(2025)
synthetic = TaijaData.load_synthetic_data()
ENV["DATADEPS_ALWAYS_ACCEPT"] = "true"

Expand Down
3 changes: 2 additions & 1 deletion docs/src/_intro.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ plot(ce)
```{julia}
#| echo: false
Random.seed!(2024)
# Data and Model:
data = TaijaData.load_gmsc(10000)
counterfactual_data = CounterfactualExplanations.DataPreprocessing.CounterfactualData(data...)
Expand Down Expand Up @@ -377,7 +379,6 @@ Currently, the following counterfactual generators are implemented:
- Generic
- GravitationalGenerator [@altmeyer2023endogenous]
- Greedy [@schut2021generating]
- GrowingSpheres [@laugel2017inverse]
- MINT [@karimi2020algorithmic] (**causal CE**)
- PROBE [@pawelczyk2022probabilistically]
- REVISE [@joshi2019realistic]
Expand Down
6 changes: 6 additions & 0 deletions docs/src/index.qmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
---
engine: julia
julia:
exeflags: ["--project=docs/"]
---

```@meta
CurrentModule = CounterfactualExplanations
```
Expand Down
Binary file modified docs/src/www/mnist_factual.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 0 additions & 41 deletions src/counterfactuals/growing_spheres.jl

This file was deleted.

2 changes: 1 addition & 1 deletion src/generative_models/encoders.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ struct Encoder
μ::Any
logσ::Any
end
Flux.@functor Encoder
Flux.@layer Encoder

function Encoder(input_dim::Int, latent_dim::Int, hidden_dim::Int; activation=sigmoid)
return Encoder(
Expand Down
2 changes: 1 addition & 1 deletion src/generative_models/vae.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function VAE(input_dim; kws...)
return VAE(encoder, decoder, args, false)
end

Flux.@functor VAE
Flux.@layer VAE

function Flux.trainable(generative_model::VAE)
return (encoder=generative_model.encoder, decoder=generative_model.decoder)
Expand Down
Loading

2 comments on commit 3961fd4

@pat-alt
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/122197

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.4.1 -m "<description of version>" 3961fd474599b059835b41cf2dc7fc37fd982c6b
git push origin v1.4.1

Please sign in to comment.