kevin-xuan / Graph-Flashback

[SIGKDD'2022] Graph-Flashback Network for Next Location Recommendation
https://dl.acm.org/doi/abs/10.1145/3534678.3539383
34 stars 7 forks source link
graph-neural-networks next-poi-recommendation spatial-temporal-knowledge-graph

SIGKDD 2022. Graph-Flashback Network for Next Location Recommendation

image

Requirements

pip install -r requirements.txt

Data Preparation

1. place flashback_data.zip into Graph_Flashback/data/ and unzip the file as following:

Graph_Flashback/data/checkins-gowalla.txt

Graph_Flashback/data/checkins-4sq.txt

2. place Graphs.zip into Graph_Flashback/KGE/ and unzip the file as following :

Graph_Flashback/KGE/Graphs/gowalla_scheme2_transe_loc_temporal_100.pkl

3. Optional, the pretrained-model are also provided, you can unzip the file into "data/" (e.g., Graph_Flashback/data/pretrained-model/gowalla_schema2) and use "scripts/construct_graphs.sh" for generating the graphs in this paper. (If you are interested in the code of pre-trained model, you can find the download link here) (including processed triplets files). Otherwise, we also provide the pure source code for training your models on your own datasets here, which needs to construct your triplets files. See Section Training new datasets for details.

4. The friend datasets have been uploaded into the data file. You can also download the user profile file by the link presented in Section 6 "EXPERIMENTS" in our paper.

Model Training

Gowalla

python train.py --trans_loc_file KGE/Graphs/gowalla_scheme2_transe_loc_temporal_100.pkl --trans_interact_file KGE/Graphs/gowalla_scheme2_transe_user-loc_100.pkl --log_file results/log_gowalla

Foursquare

python train.py --dataset checkins-4sq.txt --trans_loc_file KGE/Graphs/foursquare_scheme2_transe_loc_temporal_20.pkl --trans_interact_file KGE/Graphs/foursquare_scheme2_transe_user-loc_100.pkl --log_file results/log_foursquare

Training new datasets

In order to train your model on your own datasets, you should run "generate_triplet.py" by modifying some default settings such as dataset_file and DATA_NAME= in this line and "refine.py" to extract the final triplets files as follows:

cd KGE
python generate_triplet.py --dataset <your_dataset>.txt --friendship <your_friend>.txt 
python refine.py

Moreover, we provide the KGE code by the link, and you should delete the two original txt files: "final_test_triplets.txt" and "final_train_triplets.txt" and rename the "new_final_test_triplets.txt" into "final_test_triplets.txt", so do "new_final_train_triplets.txt", and copy the directory gowalla_scheme2 (i.e., './KGE/gowalla/gowalla_scheme2/') into the corresponding dir in KGE code, e.g., './datasets/gowalla/kg/'. The "relation2id.txt" is provided and used in same way, and the corresponding file name mapping is as follows:

entity2id.txt -> e_map.txt
final_train_triplets.txt -> train.txt
final_test_triplets.txt -> test.txt
relation2id.txt -> r_map.txt

Finally, using your pre-trained model to construct the location graph by the construct_loc_loc_graph.py, for example (see scripts/construct_graphs.sh),

cd KGE
python construct_loc_loc_graph.py --model_type transe --dataset <your_data_name> --pretrain_model <your_pretrained_model> --version scheme2 --threshold 10 --user_count 10000 --loc_count 10000 

As for training the corresponding Graph-Flashback model, please refer to Model Training or (see scripts/run.sh) .

Acknowledgements