Skip to content

Niccolo-Rocchi/BN-Privacy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

94 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Towards Privacy-Aware Bayesian Networks: A Credal Approach

Code for paper "Towards Privacy-Aware Bayesian Networks: A Credal Approach" presented at ECAI 2025.

Set up Python environment

Create and activate a Python virtual environment with:

python3 -m venv venv
source venv/bin/activate[.fish]  # use `.fish` suffix if using fish shell

Install all dependencies with:

pip install -r requirements.txt

Upgrade all Python packages with:

pip install --upgrade $(pip freeze | cut -d '=' -f 1)
pip freeze > requirements.txt

This updates the requirements file with the upgraded packages.

Experiments

<name> is the name of the experiment to run. It can be one of the following.

  1. 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.

  2. 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.

Run code

With Docker (recommended)

  1. Build the Docker image:
docker build . -t bnp:2025
  1. Run the experiment:
docker run [-d] [--rm] -v bnp:/workspace bnp:2025 python -m experiments.<name>.main
  1. Results available at:

/var/lib/docker/volumes/bnp/_data/experiments/<name>/output/.

Without Docker

  1. Run the experiment:
python -m experiments.<name>.main
  1. Results available at:

experiments/<name>/output/.

Test code

Run tests with:

pytest

Test results are available at:

test/<name>/output/.

Formatting and linting

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=venv

Analyze code by running:

pylint $(git ls-files '*.py')

Plot results

Use the Plot_results.ipynb notebook available for each experiment. Plots will be saved at: experiments/<name>/output/plots.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published