Code Monkey home page Code Monkey logo

st2vec's Introduction

ST2Vec

This is our Pytorch implementation for the paper:

Ziquan Fang, Yuntao Du, Xinjun Zhu, Danlei Hu, Lu Chen, Yunjun Gao and Christian S. Jensen. (2022). Spatio-Temporal Trajectory Similarity Learning in Road Networks. Paper in ACM DL or Paper in arXiv. In KDD'22, Washington DC, USA, August 14-18, 2022.

Introduction

ST2Vec is a representation learning based solution that considers fine-grained spatial and temporal relations between trajectories to enable spatio-temporal similarity computation in road networks.

Citation

If you want to use our codes and datasets in your research, please cite:

@inproceedings{ST2Vec22,
  author    = {Ziquan Fang and
               Yuntao Du and
               Xinjun Zhu and
               Danlei Hu and 
               Lu Chen and 
               Yunjun Gao and
               Christian S. Jensen},
  title     = {Spatio-Temporal Trajectory Similarity Learning in Road Networks},
  booktitle = {{KDD}},
  pages = {347โ€“356},
  year      = {2022}
}

Requirements

  • Ubuntu OS
  • Python >= 3.5 (Anaconda3 is recommended)
  • PyTorch 1.4+
  • A Nvidia GPU with cuda 10.2+

Datasets

  • Trajectory dataset (TDrive) and Rome are an open source data set
  • We provided the road network data and map-matching result data

Reproducibility & Training

  1. Data preprocessing (Time embedding and node embedding)

    python preprocess.py
  2. Ground truth generating (It will take a while...)

    python spatial_similarity.py
    python temporal_similarity.py
  3. Triplets generating

    python data_utils.py
  4. Training

    python main.py

st2vec's People

Contributors

xj-zhu98 avatar zealscott avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

st2vec's Issues

bug: error when run preprocess.py

Traceback (most recent call last):
File "E:\codes\github\ST2Vec\preprocess.py", line 203, in
prepare_dataset(trajfile=str(config["traj_file"]), timefile=str(config["time_file"]), kseg=config["kseg"])
File "E:\codes\github\ST2Vec\preprocess.py", line 34, in prepare_dataset
node_list_int = np.array(node_list_int)
^^^^^^^^^^^^^^^^^^^^^^^
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (29830,) + inhomogeneous part.

Q dealing with NaN in map-matched vertex sequence

Hi there. Sorry to bother again. First of all, I would like to express my gratitude for sharing your amazing work and responding the previous questions! I am trying to understand the codes for map matching part so I added the following codes to STmatching_distribution_ver.py. Hope it is correct by logic.

if __name__ == '__main__':
    import pickle
    import pandas
    fr = open("data/tdrive/st_traj/tdrive.pkl",'rb')
    trs = pickle.load(fr) 
    traj_df = pd.DataFrame([])
    for col, values in trs.iterrows():
        traj_i = pd.DataFrame(data=values['trajectory'], columns=['LON', 'LAT'])
        traj_i['TRAJ_ID'] = values['id']
        trajectory = values['trajectory']
        traj_df = pd.concat([traj_df, traj_i], axis=0)
    print("end")
    traj_task_list = data_convert(traj_df)
    mmtr_list = []
    for traj in traj_task_list:
        mmtr = trajectory_matching(traj)
        mmtr_list.append(mmtr)
    print(mmtr_list)

However, most matched vertex sequences in mmtr_list contain some nan vertices. Should I ignore nan values or just eliminate those trajectories?

Also, Could you explain a little bit more about how to get the ultimate matching_result.csv file? Maybe I'm missing something.

Thanks so much!

Zixin Qin
BJTU

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.