LPA: Location Prediction with Activity Semantics
Overview
This repository contains the code and sample data for the LPA model from our paper, Improving Next Location Prediction with Inferred Activity Semantics in Mobile Phone Data.
A brief introduction to the related research is also available on personal page. Feel free to explore 😄!
To predict the ‘where,’ do we need the ‘why’? By adding inferred travel purposes into an AI model, we find that understanding the reasons behind trips makes predictions more accurate, and considering many activity types works better than relying only on a few highly accurate ones.
Fig. 1. Diverse but uncertain inferred activities still enhance predictions.
Specifically, a semantics-enhanced framework is proposed to infer and integrate user activities into an LSTM architecture with multimodal embeddings and attention mechanisms.
Fig. 2. Research framework.
Table of contents
Structure
The repository is developed using the following libraries: Pytorch and LibCity.
Directory and file descriptions:
-
data: Contains sample data for running the framework (data format requirements align with LibCity).
-
downstream & embed: Define the LPA model for next-location prediction.
-
utils: Supplementary code for running the framework.
-
args.py: Default configuration settings for the framework.
-
dataset.py: Functions for reading and loading data.
-
evaluator.py: Evaluation functions to assess framework performance.
-
executor.py: Defines the training process of the framework.
-
pipeline.py: Pipeline for executing the framework.
-
main.py: Main script to run the framework.
-
run.sh: Shell script to run the framework with default configurations.
Quick-start
Step 1. Set Configuration in args.py
The key parameter activity_type in args.py determines the activity type integrated into the model:
- None: The model uses only location data.
- A3: The model integrates location data and primary activities (Home, Work, Non-mandatory).
- A6: The model integrates location data, primary activities, and non-mandatory activities (Home, Work, Shopping, Leisure, Eat out, Personal affairs).
Step 2. Run the Framework
Execute main.py to start the framework. Note the following:
- The configurations in
args.py are default settings.
- Any configurations set directly in
main.py will overwrite the default config.
Using the command to run the framework without modifying the code:
python main.py --pre_model_name=LPA --activity_type=A6 --dataset=data_sample
or using a shell script:
bash run.sh
Step 3. Check the Results
Upon successful completion, a cache directory will be generated containing:
- Training logs
- Cached datasets
- Model checkpoints
Citation
If you find it useful for your research or development, please consider citing our paper.
@article{IJDE2025LPA,
author = {Shen Liang and Qiuping Li and Li Zhuo and Dan Zou and Yang Xu and Suhong Zhou},
title = {Improving next location prediction with inferred activity semantics in mobile phone data},
journal = {International Journal of Digital Earth},
volume = {18},
number = {2},
pages = {2552880},
year = {2025},
publisher = {Taylor \& Francis},
doi = {10.1080/17538947.2025.2552880},
}
评论