RecGuard-DetectX is an extensible library designed to evaluate and defend against poisoning attacks in recommender systems. It provides standardized benchmarks, modular components, and realistic evaluation scenarios to support reproducible and scalable research.
-
17+ Detection Models Integrated: Includes implementations of leading detection methods from recent research for out-of-the-box comparison.
-
11+ Poisoning Attack Models Integrated: Supports a wide range of attack strategies, enabling comprehensive testing of detector robustness.
-
Scenario-aligned Injection Pipeline: The generation of poisoned instances is driven by configurable environmental setups.
-
Modular & Extensible Design: Easy to integrate new attacks, detectors, and datasets with minimal code changes.
-
Open and Reproducible: All code and experiments are released to ensure transparency and replicability.
Note:
N/Aindicates that the original paper did not explicitly name the proposed attack algorithm.
Note:
N/Aindicates that the original paper did not explicitly name the proposed detection algorithm. Additionally,RSDandSUIare detection models proposed in papers that focus on poisoning attacks, and are included here due to their effectiveness.
This library requires Python 3.10 and CUDA 12.4.
We recommend using pip for installation. Please install the following packages in order to ensure compatibility (especially for PyTorch
Geometric):
# Install PyTorch (CUDA 12.4)
pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 --index-url https://download.pytorch.org/whl/cu124
# Install PyTorch Geometric and its dependencies
pip install pyg_lib torch_scatter torch_sparse torch_cluster torch_spline_conv -f https://data.pyg.org/whl/torch-2.5.1+cu124.html
pip install torch-geometric
# Other core dependencies
pip install scikit-learn pandas packaging pyyaml higher seaborn tabulate- When generating optimization-based attacks, please ensure that all parameters are set according to the recommended configurations.
- The performance of the detection algorithm SpDetector is highly sensitive to hyperparameter settings.
- For the sake of fair comparison, some implementations in this repository may slightly differ from the original versions in the papers or official codebases.
To support reproducible evaluation, we provide both:
- Synthesized datasets that have already been injected with poisoning attacks under various experimental settings;
- Original recommender datasets used as the foundation for injection and evaluation.
| Source | Link | Notes |
|---|---|---|
| Google Drive | Download All (Google Drive) | Recommended |
| Baidu Netdisk | Download All (Baidu Netdisk) | Access code: 6666 |
After downloading, please extract the folders
data/andsave/into the root directory of the project. The framework will automatically locate and load them.
Directory Structure (after extraction)
-
/config: YAML Files -
/data: Raw Data -
/dataloader: Data Handlers -
/models: Models -
/save: Stores all essential files for evaluation scenarios. -
/utils: Utils -
main.py: Main.py -
pipeline.py: Pipeline.py
Run the following command to execute the detection task with scenario="STD" on GPU 3, and tmp models are saved in ./tmp_3/:
# an example
python main.py --scenario STD --cuda 3 --tmp_dir ./tmp_3/ --Flag_injection true --Flag_detection true --Flag_assess true --Flag_evaluation trueThe last four flags can be turned on or off depending on which stages (injection, detection, assessment, evaluation) you want to execute.