This repository contains the code used in paper
- Ubuntu OS
- Python 3.9.13 (tested)
pip install -r requirements.txt- Download arbitrary dataset (e.g., Porto) to "./data/{dataset_name}/{dataset_name}.pkl", convert it to a DataFrame containing columns ["Traj_ID", "Timestamps", "Locations", "Length"].
- Download the osm file (e.g., "portugal-latest.osm.pbf") to "./data/{dataset_name}/meta/"
- Get the .osm file of the city
python map-matching/osm_convert.py
- Get the road network files for the city (such as "porto_nodes.csv")
python map-matching/osm2roadnetwork.py
- Get the map-matched results for trajectories in "porto.pkl".
Note that even with multiprocessing, it will take a long time.
python map-matching/HMMM.py
- Data augmentation for pre-training
python preprocess/augmentation.py
- Extract road segments features
python preprocess/rs_extract.py
- Extract trajectory features.
python preprocess/feature_extract.py
- Pre-training on a large dataset, which might take a long time.
python pretrain.py
- Generate the fine-tuning dataset
python dataset_preparation.py
- Fine-tune the pre-trained encoder
If you want to train from scratch, set "self.load_pretrain" of Config() in config.py to False.
python finetune_SL.py