Code for paper "Towards Privacy-Aware Bayesian Networks: A Credal Approach" presented at ECAI 2025.
Create and activate a Python virtual environment with:
python3 -m venv venv
source venv/bin/activate[.fish] # use `.fish` suffix if using fish shellInstall all dependencies with:
pip install -r requirements.txtUpgrade all Python packages with:
pip install --upgrade $(pip freeze | cut -d '=' -f 1)
pip freeze > requirements.txtThis updates the requirements file with the upgraded packages.
<name> is the name of the experiment to run. It 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. The pipeline and results are described in the paper. -
cn_vs_noisybn: additional experiment, not reported in the paper. It compares 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.
- Build the Docker image:
docker build . -t bnp:2025- Run the experiment:
docker run [-d] [--rm] -v bnp:/workspace bnp:2025 python -m experiments.<name>.main- Results available at:
/var/lib/docker/volumes/bnp/_data/experiments/<name>/output/.
- Run the experiment:
python -m experiments.<name>.main- Results available at:
experiments/<name>/output/.
Run tests with:
pytestTest results are available at:
test/<name>/output/.
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 --max-line-length=127 --statistics --exclude=venvAnalyze code by running:
pylint $(git ls-files '*.py')Use the Plot_results.ipynb notebook available for each experiment. Plots will be saved at: experiments/<name>/output/plots.