Skip to content

πŸ”¬ [ECML-PKDD'24] This is the source code and baselines of our paper FedHCDR: Federated Cross-Domain Recommendation with Hypergraph Signal Decoupling.

License

Notifications You must be signed in to change notification settings

orion-orion/FedHCDR

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

FedHCDR: Federated Cross-Domain Recommendation with Hypergraph Signal Decoupling

Hongyu Zhang, Dongyi Zheng, Lin Zhong, Xu Yang, Jiyuan Feng, Yunqing Feng, Qing Liao*

Open Source LoveLICENSEFedHCDR
FedHCDR FedHCDR

1 Introduction

This is the source code and baselines of our ECML-PKDD'24 paper FedHCDR: Federated Cross-Domain Recommendation with Hypergraph Signal Decoupling. In this paper, we propose FedHCDR, a novel federated cross-domain recommendation framework with hypergraph signal decoupling.

2 Dependencies

Run the following command to install dependencies:

pip install -r requirements.txt

Note that my Python version is 3.8.16.

3 Dataset

We utilize publicly available datasets from the Amazon website to construct FedCDR scenarios. We select ten domains to generate three cross-domain scenarios: Food-Kitchen-Cloth-Beauty (FKCB), Sports-Clothing-Elec-Cell (SCEC), and Sports-Garden-Home-Toy (SGHT).

The preprocessed CDR datasets can be downloaded from Google Drive. You can download them and place them in the ./data path of this project.

4 Code Structure

FedHCDR
β”œβ”€β”€ LICENSE                                     LICENSE file
β”œβ”€β”€ README.md                                   README file 
β”œβ”€β”€ checkpoint                                  Model checkpoints saving directory
β”‚   └── ...
β”œβ”€β”€ data                                        Data directory
β”‚   └── ...
β”œβ”€β”€ log                                         Log directory
β”‚   └── ...
β”œβ”€β”€ models                                      Local model packages
β”‚   β”œβ”€β”€ __init__.py                             Package initialization file
β”‚   β”œβ”€β”€ dhcf                                    dhcf package
β”‚   β”‚   β”œβ”€β”€ __init__.py                         Package initialization
β”‚   β”‚   β”œβ”€β”€ dhcf_model.py                       Model architecture
β”‚   β”‚   β”œβ”€β”€ config.py                           Model configuration file
β”‚   β”‚   └── modules.py                          Backbone modules (such as hyper GCN)
β”‚   └── ...
β”œβ”€β”€ pic                                         Picture directory
β”‚   └── FedHCDR-Framework.png                   Model framework diagram
β”œβ”€β”€  utils                                      Tools such as data reading, IO functions, training strategies, etc.
β”‚    β”œβ”€β”€ __init__.py                            Package initialization file
β”‚    β”œβ”€β”€ data_utils.py                          Data reading (including ratings and graphs)
β”‚    β”œβ”€β”€ io_utils.py                            IO functions
β”‚    └── train_utils.py                         Training strategies
β”œβ”€β”€ client.py                                   Client architecture   
β”œβ”€β”€ dataloader.py                               Customized dataloader
β”œβ”€β”€ dataset.py                                  Customized dataset          
β”œβ”€β”€ fl.py                                       The overall process of federated learning
β”œβ”€β”€ local_graph.py                              Local graph and hypergraph data structure
β”œβ”€β”€ losses.py                                   Loss functions
β”œβ”€β”€ main.py                                     Main function, including the complete data pipeline
β”œβ”€β”€ requirements.txt                            Dependencies installation
β”œβ”€β”€ server.py                                   Server-side model parameters and user representations aggregation
β”œβ”€β”€ trainer.py                                  Training and test methods of FedHCDR and other baselines
└── .gitignore                                  .gitignore file

5 Train & Eval

5.1 Our method

To train FedHCDR (ours), you can run the following command:

python -u main.py \
        --num_round 60 \
        --local_epoch 3 \
        --eval_interval 1 \
        --frac 1.0 \
        --batch_size 1024 \
        --log_dir log \
        --method FedHCDR \
        --lr 0.001 \
        --seed 42 \
        --lam 2.0 \
        --gamma 2.0 \
        Food Kitchen Clothing Beauty

There are a few points to note:

  • the positional arguments Food Kitchen Clothing Beauty indicates training FedHCDR in FKCB scenario. If you want to choose another scenario, you can change it to Sports Clothing Elec Cell (SCEC) or Sports Garden Home Toys (SGHT).

  • The argument --lam is used to control local-global bi-directional knowledge transfer for FedHCDR method (ours). For FKCB, 2.0 is the best; for SCEC, 3.0 is the best; For SGHT, 1.0 is the best.

  • The argument --gamma is used to control the intensity of hypergraph contrastive learning for FedHCDR method (ours). For FKCB, 2.0 is the best; for SCEC, 1.0 is the best; For SGHT, 3.0 is the best.

  • If you restart training the model in a certain scenario, you can add the parameter --load_prep to load the dataset preprocessed (including ratings and graphs) in the previous training to avoid repeated data preprocessing.

To test FedHCDR, you can run the following command:

python -u main.py \
        --log_dir log \
        --method FedHCDR \
        --load_prep \
        --model_id 1709476223 \
        --do_eval \
        --seed 42 \
        Food Kitchen Clothing Beauty

Here --model_id is the model ID under which you saved the model before. You can check the ID of the saved models in the checkpoint/domain_{$dataset} directory.

5.2 Baselines

To train other baselines (LocalMF, LocalGNN, LocalDHCF, FedMF, FedGNN, PriCDR, FedP2FCDR, FedPPDM), you can run the following command:

python -u main.py \
        --num_round 60 \
        --local_epoch 3 \
        --eval_interval 1 \
        --frac 1.0 \
        --batch_size 1024 \
        --log_dir log \
        --method FedPPDM \
        --lr 0.001 \
        --seed 42 \
        Food Kitchen Clothing Beauty 

Here FedPPDM can be replaced with the name of the baselines you want to train.

For the local version without federated aggregation, you can run the following command:

python -u main.py \
        --num_round 60 \
        --local_epoch 3 \
        --eval_interval 1 \
        --frac 1.0 \
        --batch_size 1024 \
        --log_dir log \
        --method LocalPPDM \
        --lr 0.001 \
        --seed 42 \
        Food Kitchen Clothing Beauty 

Similarly, FedPPDM here can be replaced with the name of the baselines you want to train.

6 Citation

If you find this work useful for your research, please kindly cite FedHCDR by:

@misc{zhang2024fedhcdr,
      title={FedHCDR: Federated Cross-Domain Recommendation with Hypergraph Signal Decoupling}, 
      author={Hongyu Zhang and Dongyi Zheng and Lin Zhong and Xu Yang and Jiyuan Feng and Yunqing Feng and Qing Liao},
      year={2024},
      eprint={2403.02630},
      archivePrefix={arXiv},
      primaryClass={cs.LG}
}

About

πŸ”¬ [ECML-PKDD'24] This is the source code and baselines of our paper FedHCDR: Federated Cross-Domain Recommendation with Hypergraph Signal Decoupling.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages