The original code to Christian Löwens, Daniela Thyssens, Emma Andersson, Christina Jenkins, and Lars Schmidt-Thieme "DeepStay: Stay Region Extraction from Location Trajectories using Weak Supervision".
This work was shortlisted for the Best Paper/Student Paper Award at ITSC 2023. The preprint version can be found on arXiv.
This code was tested on CPU and GPU with the following environment:
- conda:
- python=3.10.10
- pytorch=2.0.1
- numpy=1.24.3
- pandas=1.5.3
- tqdm=4.65.0
- conda-forge:
- geopandas=0.13.0
- pip:
- tensorboard=2.13.0
- func_argparse=1.1.1
- osmnx=1.3.0
Our results can be reproduced with these four steps:
The following commands download and annotate the GeoLife (GL) and ExtraSensory (ES) datasets:
python ./data/gl_preprocessing.py
python ./data/es_preprocessing.py
To pre-train DeepStay on the GL dataset, execute the following command:
python ./src/experiment.py --data="gl" --train_data_path="./data/tmp/preprocessed/gl.pkl"
To see all adjustable parameters, call:
python ./src/experiment.py --help
After pre-training, fine-tune DeepStay on the ES dataset:
python ./src/experiment.py --data="es" --interp_sec=2 --train_data_path="./data/tmp/preprocessed/es_kfold/0_train.pkl" --pretrained_model_path="./trained_models/<PRETRAINED-MODEL-FILENAME>" --no-use_trained_decoder
Get the final model predictions for the 0_test.pkl
test set:
python ./src/evaluation.py get_model_prediction --data="es" --dataset_interp_sec=2 --testdata_filepath="./data/tmp/preprocessed/es_kfold/0_test.pkl" --model_path="./trained_models/<FINETUNED-MODEL-FILENAME>" --output_filepath="<OUTPUT_FILEPATH>"
For kfold evaluation of the baseline algorithms call:
python ./baselines/evaluation.py --output_filepath="baseline_results.csv"
Download the GL dataset as described in Experiment 1.
python ./src/experiment.py --data="tm" --train_data_path="./data/tmp/preprocessed/gl.pkl" --val_frac=0 --test_k=0
Get the final model predictions:
python ./src/evaluation.py get_model_prediction --data="tm" --testdata_filepath="./data/tmp/preprocessed/gl.pkl" --model_path="./trained_models/<TMD-MODEL-FILENAME>" --output_filepath="<OUTPUT_FILEPATH>" --tm_test_k=0