Code for paper "Imprecise Probabilities for Privacy–Accuracy Trade-offs in Bayesian Networks" presented at UAI 2026.
<name> is the name of the experiment to run. Each <name> has its own directory, which is named the same way. Each of these contains the experiment logic, configuration file (config.yaml), eventually generated models and data, output directory, and a Plot_results.ipynb notebook to plot results.
<name> can be one of the following:
-
cn_privacy: run membership inference attack against a Bayesian network (BN), its related credal network (CN), and compute the theoretical privacy estimate of BN. -
cn_vs_noisybn: compare two privacy techniques, namely the CN and a noisy version of BN. All models are naive Bayes with target variable T. First, the CN and noisy BN hyperparameters are fine-tuned so that they achieve the same privacy level; then, their accuracy is computed in terms of most probable explanation (MPE) on variable T.
For additional details, we refer to the paper.
Each experiment requires the user to specify one defense and one attack mechanisms, plus additional related hyperparameters. Below, the mechanisms and hyperparameters names are reported.
Implemented defenses:
def_idm. Requires:ess.def_ran. Requires:delta.
Implemented attacks:
atk_mle.atk_cen.atk_ran.atk_ent.
The compose.yaml file contains a set of pre-set experiments. Additional ones can also be specified. The generate_compose.py file helps in generating them automatically.
Generate models and data for all experiments (controlled by config.yaml):
python -m experiments.cn_privacy.generate
python -m experiments.cn_vs_noisybn.generateRun one or more experiments with:
docker compose up [service name]Results will be available under experiments/<name>/output_*.
To check the status, run one or more of the following:
docker compose ps
docker compose logs [service name]
docker statsCreate and activate a Python virtual environment:
python3 -m venv venv
source venv/bin/activate[.fish] # use `.fish` suffix if using fish shellInstall dependencies:
pip install -r requirements.txtNotice: if some package is missing locally, see the Dockerfile for additional packages to be installed (names refer to Ubuntu/Debian).
Upgrade dependencies:
pip install --upgrade $(pip freeze | cut -d '=' -f 1)
pip freeze > requirements.txtNotice: each of the following command will overwrite any related output.
Generate models and data (controlled by config.yaml):
python -m experiments.<name>.generateRun an experiment:
python -m experiments.<name>.exp def_mec=<def_name> [param=value] atk_mec=<def_name> [param=value]Results will be available under experiments/<name>/output.
Run integration tests:
pytest [--cov=src] [--cov-report=term-missing] [--capture=no]Format code by running:
black .
isort .Lint code by running:
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude=venv
flake8 . --count --exit-zero --max-complexity=10 --ignore=E203 --max-line-length=140 --statistics --exclude=venvAnalyze code by running:
pylint $(git ls-files '*.py')Install act:
curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bashRun act with:
sudo ./bin/act [-W <path_to_file>]