FedCCFA: Classifier Clustering and Feature Alignment for Federated Learning under Distributed Concept Drift

October 25, 2024 ยท View on GitHub

This is the implementation of our paper: Classifier Clustering and Feature Alignment for Federated Learning under Distributed Concept Drift (NeurIPS 2024). In this paper, we propose a federated learning framework with classifier clustering and feature alignment (FedCCFA).

FedCCFA

๐Ÿ“ฆ Algorithms

This repository also provides the implementations of the following methods:

Traditional Federated Learning

Personalized Federated Learning

Clustered Federated Learning

Concept Drift in Federated Learning

๐Ÿ“„ Experiments

Hyperparameters

All hyperparameters can be set in ./configs/*.yaml. Common hyperparameters in our experiments are list as follows:

HyperparameterValuesDescription
client_num20 or 10020 with full participation or 100 with 20% participation
sample_ratio1 or 0.2full participation or 20% participation
datasetFashion-MNIST or CIFAR-10 or CINIC-10Three datasets in our experiments
alpha0.1 or 0.5concentration parameter in Dirichlet distribution
drift_patternfalse / sudden / incremental / recurrentconcept drift pattern

The above numerical values (for client_num, sample_raio and alpha) are used in our experiments. You can select any value you want.

For the descriptions of other hyperparameters, please refer to our paper for more details.

Datasets

Three datasets (Fashion-MNIST, CIFAR-10 and CINIC-10) are used in our experiments. You can download these datasets and put them in ./data.

For other datasets, you can download them and implement data distribution in ./utils/gen_dataset.py.

Example for FedCCFA under sudden drift setting

Edit configs/FedCCFA.yaml (e.g., set "drift_pattern" to "sudden").

cd methods
export PYTHONPATH=../
python3 FedCCFA.py

๐Ÿ’ก Other Implementation

You can easily develop other FL algorithms by this repository.

First, create a new python script: entities/XXX.py

from entities.base import Client, Server

Class XXXClient(Client):
    def __init__(self, client_id, args, train_set, test_set, global_test_id):
        super().__init__(client_id, args, train_set, test_set, global_test_id)
    
    def train(self):
        """New local training method if needed"""
        pass


Class XXXServer(Server):
    def __init__(self, args):
        super().__init__(args)
    
    def aggregate_by_params(self, clients):
        """New aggregation method if needed"""
        pass

Then, create a new python script: methods/XXX.py. Please refer to methods/FedAvg.py to implement new FL process.

๐Ÿง‘๐Ÿปโ€๐Ÿ’ป Bugs or Questions?

If you have any questions related to the code or the paper, feel free to email Junbao (junbaochen@bit.edu.cn). If you encounter any problems when using the code, or want to report a bug, you can open an issue.

๐Ÿ“ Citation

If you find FedCCFA useful for your research, please consider citing our paper:

@article{chen2024classifier,
    title={Classifier Clustering and Feature Alignment for Federated Learning under Distributed Concept Drift},
    author={Chen, Junbao and Xue, Jingfeng and Wang, Yong and Liu, Zhenyan and Huang, Lu},
    booktitle={The Thirty-eighth Annual Conference on Neural Information Processing Systems},
    year={2024}
}