{"id":13700107,"url":"https://github.com/boathit/t2vec","last_synced_at":"2025-05-04T18:34:17.292Z","repository":{"id":41070610,"uuid":"160789898","full_name":"boathit/t2vec","owner":"boathit","description":"t2vec: Deep Representation Learning for Trajectory Similarity Computation","archived":false,"fork":false,"pushed_at":"2021-04-10T02:07:35.000Z","size":65,"stargazers_count":133,"open_issues_count":21,"forks_count":47,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-13T06:33:01.245Z","etag":null,"topics":["representation-learning","spatial-data-analysis","trajectory-embedding"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/boathit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-07T07:47:05.000Z","updated_at":"2024-10-24T06:14:54.000Z","dependencies_parsed_at":"2022-07-17T10:16:31.776Z","dependency_job_id":null,"html_url":"https://github.com/boathit/t2vec","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boathit%2Ft2vec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boathit%2Ft2vec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boathit%2Ft2vec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boathit%2Ft2vec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/boathit","download_url":"https://codeload.github.com/boathit/t2vec/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252382923,"owners_count":21739241,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["representation-learning","spatial-data-analysis","trajectory-embedding"],"created_at":"2024-08-02T20:00:48.662Z","updated_at":"2025-05-04T18:34:12.821Z","avatar_url":"https://github.com/boathit.png","language":"Python","funding_links":[],"categories":["Trajectory"],"sub_categories":[],"readme":"\nThis repository contains the code used in our **ICDE-18** paper [Deep Representation Learning for Trajectory Similarity Computation](https://xiucheng.org/pdfs/icde18-t2vec.pdf).\n\n## Requirements\n\n* Ubuntu OS\n* [Julia 1.5+](https://julialang.org/downloads/) (tested on 1.5)\n* Python \u003e= 3.8 (Anaconda3 is recommended)\n* PyTorch 1.0+ (tested on 1.0, 1.3, 1.5, 1.7)\n\nPlease refer to the source code to install all required packages in Julia and Python.\n\nYou can install all packages involved for Julia by running,\n\n```shell\n$ julia pkg-install.jl\n```\n\n\n## Preprocessing\n\nThe preprocessing step will generate all data required in the training stage.\n\n1. For the Porto dataset, you can do as follows.\n    ```shell\n    $ curl http://archive.ics.uci.edu/ml/machine-learning-databases/00339/train.csv.zip -o data/porto.csv.zip\n    $ unzip data/porto.csv.zip\n    $ mv train.csv data/porto.csv\n    $ cd preprocessing\n    $ julia porto2h5.jl\n    $ julia preprocess.jl\n    ```\n\n2. If you want to work on another city, you are supposed to provide the expected hdf5 input `t2vec/data/cityname.h5` as well as set proper hyperparameters in `t2vec/hyper-parameters.json`. The expected hdf5 input requires the following format,\n\n   ```julia\n   attributes(f)[\"num\"] = number of trajectories\n\n   f[\"/trips/i\"] = matrix (2xn)\n   f[\"/timestamps/i\"] = vector (n,)\n   ```\n\n   where `attributes(f)[\"num\"]` stores the number of trajectories in total; `f[\"/trips/i\"]` is the gps matrix for i-th trajectory, the first row is the longitude sequence and the second row is the latitude sequence, `f[\"/timestamps/i\"]` is the corresponding timestamp sequence. Please refer to [`porto2h5`](https://github.com/boathit/t2vec/blob/master/preprocessing/utils.jl#L12) to see how to generate it.\n\n\n\nThe generated files for training are saved in `t2vec/data/`.\n\n## Training\n\n```shell\n$ python t2vec.py -vocab_size 18864 -criterion_name \"KLDIV\" -knearestvocabs \"data/porto-vocab-dist-cell100.h5\"\n```\n\nwhere 18866 is the output of last stage.\n\nThe training produces two model `checkpoint.pt` and `best_model.pt`, `checkpoint.pt` contains the latest trained model and `best_model.pt` saves the model which has the best performance on the validation data. You can find our saved `best_model.pt` [here](https://drive.google.com/open?id=1uxZUmvFHhpY8tOXvCDHuEd7KFOTYp109).\n\nIn our original experiment, the model was trained with a Tesla K40 GPU about 14 hours so you can just terminate the training after 14 hours if you use a GPU that is as good as or better than K40, the above two models will be saved automatically.\n\n\n## Encoding and Experiments\n\n### Vector representation\n\nIn our experiments we train a three-layers model and the last layer outputs are used as the trajectory representations:\n\n```julia\nvecs = h5open(joinpath(\"\", \"trj.h5\"), \"r\") do f\n    read(f[\"layer3\"])\nend\n\nvecs[i] # the vector representation of i-th trajectory\n```\n\n### Experiments\n\nPlease refer to the [jupyter-notebook](https://github.com/boathit/t2vec/blob/master/experiment/t2vec.ipynb) for the experiments once you obtain the trained model (install [Ijulia](https://github.com/JuliaLang/IJulia.jl) for the Jupyter notebook first).\n\n## Reference\n\n```\n@inproceedings{DBLP:conf/icde/LiZCJW18,\n  author    = {Xiucheng Li and\n               Kaiqi Zhao and\n               Gao Cong and\n               Christian S. Jensen and\n               Wei Wei},\n  title     = {Deep Representation Learning for Trajectory Similarity Computation},\n  booktitle = {34th {IEEE} International Conference on Data Engineering, {ICDE} 2018,\n               Paris, France, April 16-19, 2018},\n  pages     = {617--628},\n  year      = {2018},\n  crossref  = {DBLP:conf/icde/2018},\n  url       = {https://doi.org/10.1109/ICDE.2018.00062},\n  doi       = {10.1109/ICDE.2018.00062},\n  timestamp = {Tue, 20 Nov 2018 10:20:00 +0100},\n  biburl    = {https://dblp.org/rec/bib/conf/icde/LiZCJW18},\n  bibsource = {dblp computer science bibliography, https://dblp.org}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboathit%2Ft2vec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fboathit%2Ft2vec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboathit%2Ft2vec/lists"}