This repository contains the implementation of our paper accepted at KDD 2026: "LATTE: Learning Adaptive Segmentation for Efficient and Effective Trajectory Similarity Learning"
First download the trajectory dataset used in our paper, or your own dataset into ./data/{dataset_name}. You need to extend config.py if it is your own dataset.
The preprocessing pipeline is organized under preprocess/ and should be run in the following order:
Step 1. Trajectory map matching (map_matching/): osm_convert.py → osm2roadnetwork.py → HMMM_mm.py → filter.py
Step 2. Meta Feature extraction (meta_feature/): meta_feature.py
Step 3. Trajectory interpolation (interpolation/): interpolation.py
Step 4. Dataset split (dataset_split/): dataset_split.py
Step 5. Feature extraction (feature_extraction/): segment_graph.py → node2vec.py, feature_tokenization.py, feature_extract.py (last three are independent and can run in parallel)
Step 6. TSL label generation (similarity_ground_truth/): initialization.py → dataset_preparation.py
First train the teacher model:
python train_teacher.py -root_dir YOUR_DATA_DIR -dataset_name portoThen train LATTE:
python train_LATTE.py -root_dir YOUR_DATA_DIR -dataset_name portoKey configuration arguments:
| Argument | Description | Default |
|---|---|---|
-root_dir |
Path to data directory | "your/project" |
-dataset_name |
Dataset name (porto, chengdu) |
porto |
-split_marker |
Trajectory length split (short, long) |
short |
-distance_type |
Similarity metric (TP, NetERP) |
TP |
-epochs |
Number of training epochs | 20 |
-batch_size |
Batch size | 32 |
-num_companion |
Number of positive/negative companions per anchor | 5 |
-target_ratio |
Target segmentation ratio for AdaSeg | 0.2 |
