[![INFORMS Journal on Computing Logo](https://INFORMSJoC.github.io/logos/INFORMS_Journal_on_Computing_Header.jpg)](https://pubsonline.informs.org/journal/ijoc)

# Privacy Protection and Statistical Efficiency Trade-off for Federated Learning
This archive is distributed in association with the [INFORMS Journal on Computing](https://pubsonline.informs.org/journal/ijoc) under the [MIT License](LICENSE.txt).

The software and data in this repository are a snapshot of the software and data that were used in the research reported on in the paper [Privacy Protection and Statistical Efficiency Trade-off for Federated Learning](https://doi.org/10.1287/ijoc.2024.0554) by Haobo Qi and Feifei Wang and Hansheng Wang.

## Cite
To cite the contents of this repository, please cite both the paper and this repo, using their respective DOIs.

https://doi.org/10.1287/ijoc.2024.0554

https://doi.org/10.1287/ijoc.2024.0554.cd

Below is the BibTex for citing this snapshot of the repository.
```
@misc{Qi2025,
  author =        {Haobo Qi and Feifei Wang and Hansheng Wang},
  publisher =     {INFORMS Journal on Computing},
  title =         {{Privacy Protection and Statistical Efficiency Trade-off for Federated Learning}},
  year =          {2025},
  doi =           {10.1287/ijoc.2024.0554.cd},
  url =           {https://github.com/INFORMSJoC/2024.0554},
  note =          {Available for download at https://github.com/INFORMSJoC/2024.0554},
}  
```


## Folder Structure
   * `src` Contains our model implementation and training codes.
     
      - `linear_xxxx.py`: Implementations based on linear models.
        
        1. `basic`: Codes for basic comparison experiments for FGD, NA-FGD and, ANA-FGD with varying sample size $n$, number of client $K$, and privacy budget $\varepsilon$.
        2. `comparison`: Codes for extensive comparison experiments for FGD, ANA-FGD, NbAFL, and Opacus with varying sample size $n$, and privacy budget $\varepsilon$.
        3. `laplacemechanism`: Codes for basic comparison experiments for FGD, NA-FGD and, ANA-FGD with Laplacian mechanism.
        4. `learningrate`: Codes for basic comparison experiments for FGD, NA-FGD and, ANA-FGD with polynomial diminishing learning rates.
        5. `unbalance`: Codes for extensive comparison experiments for FGD, ANA-FGD, NbAFL, and Opacus with unbalanced local sample size $n_k$s.
           
      - `logit_basic.py`: Codes for basic comparison experiments for FGD, NA-FGD and, ANA-FGD with varying sample size $n$, number of client $K$, and privacy budget $\varepsilon$ based on logistic regression model.
        
      - `poisson_basic.py`: Codes for basic comparison experiments for FGD, NA-FGD and, ANA-FGD with varying sample size $n$, number of client $K$, and privacy budget $\varepsilon$ based on poisson regression model.
        
      - `FLDP_utlis.py`: Codes for basic functions in simulation experiments.
  
  
  * `results` Contains: - Ablation study results - Code for generating result visualizations



## Preparation

Install the required dependencies:
```
pip install -r requirements.txt
```


## Implementation

Enter the `src` directory:
```
cd src
```

Run the following command to replicate the simulation results:
```
python linear_xxxx.py       # Simulation studies for linear models
python logit_basic.py       # Simulation studies for linear models
python poisson_basic.py     # Simulation studies for linear models
```
* `xxxx` in `linear_xxxx.py` represents different experiment settings. Detailed information can be found in Section "Folder Structure".
* The simulation results are saved in the current directory by default. If you need to adjust this, please modify it in the above `.py` files.
* Once you collect the simulation results, you can use the plot codes `/results/FLDP_plot.ipynb` to replicate the figures.


## Remark

We would like to kindly note that the codes and results provided in this repository pertain to our simulation study. The real-world dataset used in the empirical experiments i.e., the dataset from NIO enterprise community (https://app-intl.nio.com), involves proprietary commercial data and is subject to confidentiality agreements. As such, we regret that we are unable to share this dataset and its corresponding codes publicly. The detailed, available information of our real data analysis can be found in our manuscript and supplementary materials.
