Metadata-Version: 2.4
Name: BenchmarkDPFair
Version: 0.2.3
Summary: A differentially private data synthesizer and fairness intervention benchmark framework
Author-email: Vinicius Gabriel Angelozzi Verona de Resende <verona.projects@tutanota.com>, HÃ©ber Hwang Arcolezi <heber.hwang-arcolezi@etsmtl.ca>
License: MIT License
        
        Copyright (c) 2025 Vinicius Gabriel Angelozzi Verona de Resende, Héber Hwang Arcolezi
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/vinicius-verona/dp-fair-intervention-benchmark
Project-URL: Issues, https://github.com/vinicius-verona/dp-fair-intervention-benchmark/issues
Requires-Python: <3.13,>=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: aif360>=0.6.1
Requires-Dist: aif360[inFairness]>=0.6.1
Requires-Dist: fairlearn>=0.12.0
Requires-Dist: inFairness>=0.2.3
Requires-Dist: matplotlib>=3.9.4
Requires-Dist: matplotlib-inline>=0.1.7
Requires-Dist: numpy>=1.26.4
Requires-Dist: pandas>=2.2.3
Requires-Dist: scikit-learn>=1.6.1
Requires-Dist: scipy>=1.13.1
Requires-Dist: smartnoise-sql>=1.0.6
Requires-Dist: smartnoise-synth>=1.0.5
Requires-Dist: tabulate>=0.9.0
Requires-Dist: ucimlrepo>=0.0.7
Requires-Dist: xgboost>=2.1.1
Requires-Dist: cvxpy>=1.6.5
Requires-Dist: chex>=0.1.87
Requires-Dist: BlackBoxAuditing==0.1.54
Dynamic: license-file

# DP+Fair Benchmarking Framework

This repository provides a Python framework for **benchmarking fairness mechanisms** on **Differentially Private Synthetic Data**.  


---

## Features

- ⚡ Simple, reproducible setup for benchmarking algorithms  
- 🧩 Flexible API to plug in any classifier implementing `fit`, `predict`, and `predict_proba`  
- 📊 Pre-offered datasets included under [`data/`](https://github.com/vinicius-verona/dp-fair-intervention-benchmark/tree/dev/data)  
- 🔬 Configurable experiment settings: dataset schema, dataset synthesizer, seeds, privacy-budget, input/outputs, classifier, data pre-processing.  

---

## Installation

> From source
To install, clone the repository and install dependencies:

```bash
git clone https://github.com/vinicius-verona/dp-fair-intervention-benchmark.git
cd dp-fair-intervention-benchmark
pip install -e .
```

> Using PyPi **(SUGGESTED)**
```bash
pip install BenchmarkDPFair
````

---

## Repository Structure

```
├── data/         # Pre-offered datasets
├── src/          # Core source code
├── examples/     # Some demo
├── tests/        # Unit tests
└── README.md
```

---

## Quick Start

Here is a dummy example:

```python
import argparse
from typing import List, Union
from BenchmarkDPFair.DataGenerator import generate_data, DatasetGeneratorConfig
from BenchmarkDPFair.Benchmark import benchmark, BenchmarkInfo, BenchmarkDatasetConfig

from sklearn.linear_model import LogisticRegression

ESTIMATOR_PARAMS = {
    'max_iter': 10000,
    'solver': 'saga',
    'l1_ratio': 0.5,
    'C': 0.8
}

lr = LogisticRegression
classifiers = [lr]
ckwargs = [
    ESTIMATOR_PARAMS,
]
classifier_name = ["LR"]
combinations = [
    (0, 0),
    (0, 1),
]

synths = ["aim", "mst"]

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Arguments of Data Generation for Adult")

    parser.add_argument(
        "--seeds", "-s",
        nargs="+",        # 1 or more values
        type=int          # convert automatically to int
    )

    args = parser.parse_args()
    seeds = args.seeds
    
    eps : List[Union[int,float]] = [.05, .1]

    for synthesizer in synths:
        for s in seeds:
            data_conf = DatasetGeneratorConfig(
                name = "Compas",
                target= "two_year_recid",
                synthesizer = synthesizer,
                root_dir="./data",
                sensitive_attr = "race",
                categorical_cols = ['race', 'score_text', 'c_charge_degree','age', 'sex', 'two_year_recid'],
                sensitive_cols = ['race', 'sex'],
                ordinal_cols = ['priors_count'],
                privacy_budgets=eps,
                binary_encoder=binary_encode,
                seed = s,
                test_split_size=0.4,
                data_filter = filter_compas
            )

            generate_data(f"compas.csv", "", data_conf, "./data", verbose=True)

    for clf_idx, syn_idx in combinations:
        classifier = classifiers[clf_idx]
        synth = synths[syn_idx]

        benchmark_config = BenchmarkInfo(
            dp_method=synth,
            output_dir=f"./output/Dummy-Compas/{classifier_name[clf_idx]}/",
            seeds=seeds,
            eps = eps,
            classifier=classifier,
            classifier_kwargs=ckwargs[clf_idx]
        )

        benchmark_dataset = BenchmarkDatasetConfig(
            name = "Compas",
            target= "two_year_recid",
            root_dir="./data",
            sensitive_attr = "race",
            index_col="Unnamed: 0",
            categorical_cols = ['race', 'score_text', 'c_charge_degree','age', 'sex', 'two_year_recid'],
            ordinal_cols=["priors_count"],
            sensitive_cols = ['race', 'sex'],
        )


        benchmark(benchmark_info=benchmark_config, data_conf=benchmark_dataset)
```

More detailed examples can be found in the [`example/`](https://github.com/vinicius-verona/dp-fair-intervention-benchmark/tree/dev/example) directory.

---

## License

License: **MIT**

---

## Contributing

Contributions are welcome:
* Open an issue for bug reports or feature requests

---
