HyperDFI is a PyTorch-based graph learning project for drug-food interaction prediction. The code builds a bipartite drug-food graph, learns drug and food representations with graph and hypergraph propagation, and predicts interaction labels with a classifier.
The current codebase is adapted for:
- Drug-food interaction prediction
- Bipartite graph representation learning
The dataset loader expects interaction triples in CSV format:
drug_id,food_id,relation
HyperDFI/
├── Code/
│ ├── Main.py
│ ├── Model.py
│ ├── DataLoader.py
│ ├── Params.py
│ └── Utils/
│ ├── RunLogger.py
│ └── Utils.py
└── Data/
└── DrugBank-df/
└── transductive/
├── train.csv
└── test.csv
Code/Main.py: training and evaluation entry pointCode/Model.py: model definitionCode/DataLoader.py: dataset loading, ID remapping, adjacency constructionCode/Params.py: command-line hyperparametersCode/Utils/RunLogger.py: simple runtime loggerCode/Utils/Utils.py: loss and normalization helpers
The model contains three main parts:
- Embedding layer Initializes learnable embeddings for drugs and foods.
- Graph propagation Uses a GCN-style sparse propagation layer on the bipartite adjacency matrix.
- Hypergraph propagation Uses hypergraph-style transformations to capture higher-order structure.
- Classifier Concatenates drug and food embeddings and predicts the interaction label.
The final embedding is the sum of propagated representations across layers.
Code/DataLoader.py performs the following steps:
- Reads
train.csvandtest.csv - Renames columns internally as
drug_nodes,food_nodes, andrelations - Maps raw drug and food IDs to contiguous indices
- Builds the label matrix
- Creates sparse training and testing interaction matrices
- Converts the bipartite adjacency matrix to a CUDA sparse tensor
- Wraps samples into PyTorch
DataLoaderobjects
Recommended environment:
- Python 3.9+
- PyTorch
- NumPy
- pandas
- SciPy
- scikit-learn
- wandb
You can install the common dependencies with:
pip install torch numpy pandas scipy scikit-learn wandbRun from the Code directory:
cd Code
python Main.pyExample with explicit parameters:
python Main.py --data DrugBank-df --epoch 100 --batch 1024 --lr 1e-3 --gpu 0The training script:
- loads the dataset
- initializes the model and optimizer
- trains for multiple epochs
Reported metrics include:
- Accuracy
- Precision
- F1
- AUC
- AUPR
- The code currently uses CUDA tensors in several places, so GPU execution is expected by default.
- The dataset path is resolved relative to the
Codedirectory.
If you use this repository in your work, cite the corresponding paper or project source that this implementation is based on, and describe your drug-food adaptation clearly.