Skip to content
Snippets Groups Projects
Unverified Commit 9ab6bd69 authored by Pat Alt's avatar Pat Alt Committed by GitHub
Browse files

Merge pull request #11 from pat-alt/10-polish-this-repo

10 polish this repo
parents 1c6cd90b 2be8342e
No related branches found
No related tags found
No related merge requests found
# ECCCo
[![Build Status](https://github.com/pat-alt/ECCCo.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/pat-alt/ECCCo.jl/actions/workflows/CI.yml?query=branch%3Amain)
![](artifacts/results/images/poc_gradient_fields.png)
*Energy-Constrained Counterfactual Explanations.*
This work is currently undergoing peer review. This README is therefore only meant to provide reviewers access to the code base. The code base will be made public after the review process.
## Inspecting the Package Code
This code base is structured as a Julia package. The package code is located in the `src/` folder.
## Inspecting the Code for Experiments
We used [Quarto](https://quarto.org/) notebooks for prototyping and running experiments. The notebooks are located in the `notebooks/` folder, separated by dataset:
- [Linearly Separable](notebooks/linearly_separable.qmd)
- [Moons](notebooks/moons.qmd)
- [Circles](notebooks/circles.qmd)
- [MNIST](notebooks/mnist.qmd)
- [GMSC](notebooks/gmsc.qmd)
Instead of looking at the notebooks directly, you may choose to browse the HTML book contained inside the `docs` folder. The book is automatically generated from the notebooks and includes all code chunks and their outputs. It is currently not possible to view the book online, but you can download the `docs/` folder and open the `index.html` file in your browser.
## Inspecting the Results
All results have been carefully reported either in the paper itself or in the supplementary material. In addition, we have released our results as binary files. These will be made publicly available after the review process.
## Reproducing the Results
To reproduce the results, you need to install the package, which will automatically install all dependencies. Since the package is not publicly registered and you are looking at an anonymous repository that [cannot be cloned](https://anonymous.4open.science/faq#download), unfortunately, it is not possible to easily install the package and reproduce the results at this stage of the review process.
However, provided that the package is indeed installed, you can reproduce the results by either running the experiments in the `experiments/` folder or using the notebooks listed above for a more interactive process.
### Command Line
The `experiments/` folder contains separate Julia scripts for each dataset and a [run_experiments.jl](experiments/run_experiments.jl) that calls the individual scripts. You can either cun these scripts inside a Julia session or just use the command line to execute them as described in the following.
To run the experiment for a single dataset, (e.g. `linearly_separable`) simply run the following command:
```shell
DATANAME=linearly_separable
julia experiments/run_experiments.jl
```
We use the following identifiers:
- `linearly_separable` (*Linearly Separable* data)
- `moons` (*Moons* data)
- `circles` (*Circles* data)
- `mnist` (*MNIST* data)
- `gmsc` (*GMSC* data)
To run all experiments at once you can instead just specify `DATANAME=all`.
Pre-trained versions of all of our black-box models have been archived as `Pkg` [artifacts](https://pkgdocs.julialang.org/v1/artifacts/) and are used by default. Should you wish to retrain the models as well, simply run the following command:
```shell
DATANAME=linearly_separable
RETRAIN=true
julia experiments/run_experiments.jl
```
When running the experiments from the command line, the parameter choices used in the main paper are applied by default. To have control over these choices, we recommend you instead rely on the notebooks.
### Notebooks
To run the notebooks and ensure that all package dependencies are installed, you need to clone this repo and open it on your device. The first cell in each notebook sets up the environment. You may have to [instantiate](https://pkgdocs.julialang.org/v1/api/#Pkg.instantiate) the local environment once. Should you prefer working with Jupyter notebooks instead of Quarto, you can easily [convert](https://quarto.org/docs/tools/vscode-notebook.html#converting-notebooks) them through a single command.
No preview for this file type
No preview for this file type
No preview for this file type
bib.bib 0 → 100644
This diff is collapsed.
include("linearly_separable.jl")
include("moons.jl")
include("circles.jl")
include("mnist.jl")
include("gmsc.jl")
#!/bin/bash
SCRIPT_FOLDER="$(cd "$(dirname $0)" && pwd)"
USERNAME=${1:-vscode}
if [ -z $HOME ]; then
HOME="/root"
fi
FAILED=()
echoStderr()
{
echo "$@" 1>&2
}
check() {
LABEL=$1
shift
echo -e "\n🧪 Testing $LABEL"
if "$@"; then
echo "✅ Passed!"
return 0
else
echoStderr "❌ $LABEL check failed."
FAILED+=("$LABEL")
return 1
fi
}
checkMultiple() {
PASSED=0
LABEL="$1"
echo -e "\n🧪 Testing $LABEL."
shift; MINIMUMPASSED=$1
shift; EXPRESSION="$1"
while [ "$EXPRESSION" != "" ]; do
if $EXPRESSION; then ((PASSED++)); fi
shift; EXPRESSION=$1
done
if [ $PASSED -ge $MINIMUMPASSED ]; then
echo "✅ Passed!"
return 0
else
echoStderr "❌ $LABEL check failed."
FAILED+=("$LABEL")
return 1
fi
}
checkOSPackages() {
LABEL=$1
shift
echo -e "\n🧪 Testing $LABEL"
if dpkg-query --show -f='${Package}: ${Version}\n' "$@"; then
echo "✅ Passed!"
return 0
else
echoStderr "❌ $LABEL check failed."
FAILED+=("$LABEL")
return 1
fi
}
checkExtension() {
# Happens asynchronusly, so keep retrying 10 times with an increasing delay
EXTN_ID="$1"
TIMEOUT_SECONDS="${2:-10}"
RETRY_COUNT=0
echo -e -n "\n🧪 Looking for extension $1 for maximum of ${TIMEOUT_SECONDS}s"
until [ "${RETRY_COUNT}" -eq "${TIMEOUT_SECONDS}" ] || \
[ ! -e $HOME/.vscode-server/extensions/${EXTN_ID}* ] || \
[ ! -e $HOME/.vscode-server-insiders/extensions/${EXTN_ID}* ] || \
[ ! -e $HOME/.vscode-test-server/extensions/${EXTN_ID}* ] || \
[ ! -e $HOME/.vscode-remote/extensions/${EXTN_ID}* ]
do
sleep 1s
(( RETRY_COUNT++ ))
echo -n "."
done
if [ ${RETRY_COUNT} -lt ${TIMEOUT_SECONDS} ]; then
echo -e "\n✅ Passed!"
return 0
else
echoStderr -e "\n❌ Extension $EXTN_ID not found."
FAILED+=("$LABEL")
return 1
fi
}
checkCommon()
{
PACKAGE_LIST="apt-utils \
git \
openssh-client \
less \
iproute2 \
procps \
curl \
wget \
unzip \
nano \
jq \
lsb-release \
ca-certificates \
apt-transport-https \
dialog \
gnupg2 \
libc6 \
libgcc1 \
libgssapi-krb5-2 \
liblttng-ust0 \
libstdc++6 \
zlib1g \
locales \
sudo"
# Actual tests
checkOSPackages "common-os-packages" ${PACKAGE_LIST}
checkMultiple "vscode-server" 1 "[ -d $HOME/.vscode-server/bin ]" "[ -d $HOME/.vscode-server-insiders/bin ]" "[ -d $HOME/.vscode-test-server/bin ]" "[ -d $HOME/.vscode-remote/bin ]" "[ -d $HOME/.vscode-remote/bin ]"
check "non-root-user" id ${USERNAME}
check "locale" [ $(locale -a | grep en_US.utf8) ]
check "sudo" sudo echo "sudo works."
check "zsh" zsh --version
check "oh-my-zsh" [ -d "$HOME/.oh-my-zsh" ]
#check "login-shell-path" [ -f "/etc/profile.d/00-restore-env.sh" ]
check "code" which code
}
reportResults() {
if [ ${#FAILED[@]} -ne 0 ]; then
echoStderr -e "\n💥 Failed tests: ${FAILED[@]}"
exit 1
else
echo -e "\n💯 All passed!"
exit 0
fi
}
fixTestProjectFolderPrivs() {
if [ "${USERNAME}" != "root" ]; then
TEST_PROJECT_FOLDER="${1:-$SCRIPT_FOLDER}"
FOLDER_USER="$(stat -c '%U' "${TEST_PROJECT_FOLDER}")"
if [ "${FOLDER_USER}" != "${USERNAME}" ]; then
echoStderr "WARNING: Test project folder is owned by ${FOLDER_USER}. Updating to ${USERNAME}."
sudo chown -R ${USERNAME} "${TEST_PROJECT_FOLDER}"
fi
fi
}
\ No newline at end of file
#!/bin/bash
cd $(dirname "$0")
source test-utils-no-lc.sh vscode
# Run common tests
checkCommon
# Definition specific tests
checkExtension "julialang.language-julia"
check "julia" julia --version
# Report result
reportResults
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment