The Impact of Artificial Client Data Generation Parameters on the Performance of Federated Learning Systems
This repository contains the implementation developed as part of a master's thesis investigating how artificial client data generation and data distribution parameters affect the performance of federated learning systems.
The project provides a configurable federated learning pipeline for creating heterogeneous client datasets, training image-classification models across multiple federated clients, and evaluating the resulting global model.
The system is implemented in Python using the Flower federated learning framework and PyTorch.
Research status: This repository contains research code developed for thesis experiments. It is intended for research, reproducibility, and portfolio purposes rather than production deployment.
Federated learning performance can depend strongly on how data is distributed across participating clients.
This project investigates the effect of different artificial client-data generation approaches, including:
- random client data distribution
- quantity-skewed distributions
- feature-based client splitting
- image manipulation
- image preprocessing and augmentation
The resulting federated models can then be compared using common classification metrics.
The main workflow is:
Input dataset
│
▼
Data loading
│
▼
Client data splitting
│
▼
Optional image manipulation
│
▼
Optional image preprocessing
│
▼
Client datasets
│
▼
Federated training with Flower
│
├── Client 0
├── Client 1
├── ...
└── Client N
│
▼
FedAvg aggregation
│
▼
Global model
│
▼
Server-side benchmark evaluation
│
▼
Experiment metrics
The data preparation code is located in:
fl_base_code/data_loader/
The codebase contains implementations for three client splitting approaches:
- random splitting
- quantity-skew splitting using a Dirichlet distribution
- feature-based splitting
The selected splitting configuration is defined in config.yaml.
The data manipulation module contains configurable image transformations including:
- contrast adjustment
- brightness adjustment
- white-balance adjustment
- Gaussian noise
- edge filtering
- sharpening and blurring
Manipulation parameters can be configured in config.yaml.
The preprocessing module includes:
- horizontal flipping
- image rotation
Both transformations can be applied to client image datasets.
Federated learning is implemented using the Flower framework.
The system consists of:
- a Flower server
- multiple Flower clients
- local PyTorch model training
- FedAvg aggregation
- configurable federated training rounds
- configurable number of clients
The run_federated_learning.py script prepares the data and starts the server and client processes.
The model configuration provides two model categories:
custom_cnntransformer
The custom CNN architecture is configurable through parameters such as:
- convolutional layers
- pooling layers
- fully connected layers
- activation functions
- dropout
The transformer configuration includes torchvision model options such as:
vit_b_16vit_l_16swin_bswin_l
The configuration also allows pretrained weights to be enabled for transformer models.
The global model is evaluated on a benchmark dataset on the server side.
The evaluation code calculates:
- loss
- accuracy
- macro precision
- macro recall
- macro F1-score
The evaluation also stores labels and model predictions.
Experiment metrics and the experiment configuration are saved as JSON output inside the experiments/ directory.
Federated-Learning-System/
│
├── data-cleaner-and_exploration/
│ ├── data_cleaner.ipynb
│ └── data_exploration.ipynb
│
├── final_data/
│ └── .gitkeep
│
├── fl_base_code/
│ │
│ ├── benchmark_data/
│ │
│ ├── client/
│ │ ├── __init__.py
│ │ ├── client.py
│ │ ├── model_creator.py
│ │ └── utils.py
│ │
│ ├── data_loader/
│ │ ├── __init__.py
│ │ ├── data_manipulation.py
│ │ ├── data_preprocessing.py
│ │ ├── data_splitter.py
│ │ ├── main.py
│ │ └── utils.py
│ │
│ ├── experiments/
│ │ ├── FairnessAnalysis.ipynb
│ │ ├── MultiClient.ipynb
│ │ ├── client_visualizations.ipynb
│ │ ├── multiple_experiment_analysis.ipynb
│ │ ├── splitcompare.ipynb
│ │ └── visualizations.ipynb
│ │
│ ├── preprocessed_data/
│ │
│ ├── server/
│ │ ├── __init__.py
│ │ ├── MetricSaver.py
│ │ ├── model_creator.py
│ │ ├── server.py
│ │ └── utils.py
│ │
│ ├── __init__.py
│ ├── config.yaml
│ └── run_federated_learning.py
│
├── .gitattributes
├── .gitignore
├── README.md
└── requirements.txt
The Python dependencies currently defined in requirements.txt are:
torch~=2.3.1+cu121
pandas~=2.2.2
yaml~=0.2.5
pyyaml~=6.0.1
pillow~=10.2.0
scikit-learn~=1.5.2
torchvision~=0.18.1+cu121
flwr~=1.8.0
numpy~=1.26.4
timm~=1.0.11
opencv-python~=4.10.0.84
Clone the repository:
git clone https://github.com/shuvanon/Federated-Learning-System.git
cd Federated-Learning-SystemCreate a Python virtual environment:
python -m venv .venvActivate the environment.
.venv\Scripts\activatesource .venv/bin/activateInstall the dependencies:
pip install -r requirements.txtThe current requirements include CUDA 12.1 builds of PyTorch and torchvision.
The repository does not include the source image dataset inside final_data/; the directory currently contains only .gitkeep.
Dataset paths are configured in:
fl_base_code/config.yaml
The main data configuration contains:
data:
csv_file: ...
img_dir: ...
preprocessed_data_dir: ...
save_split: ...
clean_data_before_run: ...
batch_size: ...
train_split: ...
label_column_index: ...The current committed configuration contains local Windows paths, so these paths need to match the dataset location on the machine running the experiment.
Benchmark settings are also stored in config.yaml:
benchmark:
csv_file: ...
img_dir: ...
benchmark_percentage: ...
save_benchmark: ...The server loads this benchmark dataset and evaluates the global model during federated training.
The main experiment configuration file is:
fl_base_code/config.yaml
experiment_name: "Baseline"The configuration contains:
use_split_strategy: "random"and configuration entries for:
random
quantity_skew
feature_based
The top-level manipulation selection is configured through:
use_manipulation_technique: "none"The configuration contains parameters for:
contrast
brightness
white_balance
gaussian_noise
edge_filter
sharpening_blurring
The preprocessing selection is configured through:
use_preprocessing_technique: "none"The preprocessing configuration contains:
fixed_flip
rotation
The model type is selected through:
model:
type: "custom_cnn"The configuration contains parameters for both:
custom_cnn
transformer
Local model training parameters include:
training:
epochs: 100
learning_rate: 0.0001The configuration also contains:
- server address
- client address
- number of federated rounds
- number of clients
After configuring the dataset and experiment settings, run the pipeline from the repository root:
python fl_base_code/run_federated_learning.pyThe launcher:
- executes the data loader,
- prepares client data,
- starts the Flower server,
- starts the configured client processes,
- waits for the client processes to complete.
Experiment output is stored under:
fl_base_code/experiments/
The repository also contains the following analysis notebooks:
FairnessAnalysis.ipynb
MultiClient.ipynb
client_visualizations.ipynb
multiple_experiment_analysis.ipynb
splitcompare.ipynb
visualizations.ipynb
These notebooks are used for visualising and analysing client distributions and federated learning experiment results.
The repository contains separate notebooks for dataset cleaning and exploration:
data-cleaner-and_exploration/
├── data_cleaner.ipynb
└── data_exploration.ipynb
Shuvanon Razik
Friedrich-Alexander-Universität Erlangen-Nürnberg (FAU)
Email: shuvanon.razik@fau.de