Giter Site home page Giter Site logo

vonfeng / deepmove Goto Github PK

View Code? Open in Web Editor NEW
142.0 3.0 54.0 146.06 MB

Codes for WWW'18 Paper-DeepMove: Predicting Human Mobility with Attentional Recurrent Network

License: GNU General Public License v2.0

Python 100.00%
mobility-trajectory attention www prediction

deepmove's Introduction

DeepMove

PyTorch implementation of WWW'18 paper-DeepMove: Predicting Human Mobility with Attentional Recurrent Networks link

Datasets

The sample data to evaluate our model can be found in the data folder, which contains 800+ users and ready for directly used. The raw mobility data similar to ours used in the paper can be found in this public link.

Requirements

cPickle is used in the project to store the preprocessed data and parameters. While appearing some warnings, pytorch 0.3.0 can also be used.

Project Structure

  • /codes
  • /pretrain
    • /simple
    • /simple_long
    • /attn_local_long
    • /attn_avg_long_user
  • /data # preprocessed foursquare sample data (pickle file)
  • /docs # paper and presentation file
  • /resutls # the default save path when training the model

Usage

  1. Load a pretrained model:
python main.py --model_mode=attn_avg_long_user --pretrain=1

The codes contain four network model (simple, simple_long, attn_avg_long_user, attn_local_long) and a baseline model (Markov). The parameter settings for these model can refer to their res.txt file.

model_in_code model_in_paper top-1 accuracy (pre-trained)
markov markov 0.082
simple RNN-short 0.096
simple_long RNN-long 0.118
attn_avg_long_user Ours attn-1 0.133
attn_local_long Ours attn-2 0.145
  1. Train a new model:
python main.py --model_mode=attn_avg_long_user --pretrain=0

Other parameters (refer to main.py):

  • for training:
    • learning_rate, lr_step, lr_decay, L2, clip, epoch_max, dropout_p
  • model definition:
    • loc_emb_size, uid_emb_size, tim_emb_size, hidden_size, rnn_type, attn_type
    • history_mode: avg, avg, whole

Others

Batch version for this project will come soon.

deepmove's People

Contributors

vonfeng 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

deepmove's Issues

ValueError: could not convert string to float

Hi,Jie Feng
I am sorry to bother you. Your work is perfect, but I have encountered some minor problems when running the code.
When I run main.py as instructed, I get a ValueError: could not convert string to float at
data = pickle.load(open(self.data_path + self.data_name + '.pk', 'rb'))
I am running under Python 2.7.16 and ubuntu 18.04

questions about the dataset.

Hi Jie, thank you for sharing.

I have two questions about the dataset:

  • how to generate the tweets_clean.txt
  • and what's the meaning of each filed in tweets_clean.txt

Thank you for your time, :P

Exception has occurred: UnicodeDecodeError

Exception has occurred: UnicodeDecodeError
'ascii' codec can't decode byte 0xeb in position 2: ordinal not in range(128)

Hi vonfeng,when I execute data = pickle.load(open(self.data_path + self.data_name + '.pk', 'rb'))
it occur the exception.Could you please tell me the reason and how to load the data correctly? thanks

about foursquare.pk

Hi Jie, thanks for your sharing!
I have benefited a lot after reading your paper, but I have some questions about the attributes in the foursquare.pk file.Could you explain this file?
Thank you!

Testing

Python versions and slight changes in the code for testing with current versions.

Compatibility with Python 3.7 with no GPU

Hello, Thank you for this very interesting work! If anyone wants to run this on Python 3.7 with no cuda enabled, you need to do the following changes.

  1. import cPickle as pickle -> import pickle

  2. Avoid error while reading ASCII with pickle

data = pickle.load(open(self.data_path + self.data_name + '.pk', 'rb')) - >

with open(self.data_path + self.data_name + '.pk', 'rb') as f:
            u = pickle._Unpickler(f)
            u.encoding = 'latin1'
            data = u.load()
  1. There is a race condition occuraing while creating directories

os.mkdir(SAVE_PATH + tmp_path) - > os.makedirs(SAVE_PATH + tmp_path, exist_ok=True)

Missing indentations

Hi, Jie
Sorry to bother you. Your work is excellent, but I have encountered some minor problems when reading the code.
At train.py in codes document, when defining generate_input_long_history2, there may be missing an indentation at every line from 145 to 154.

An indent bug in train.py

DeepMove/codes/train.py

Lines 143 to 154 in 0acff5d

for c, i in enumerate(train_id):
session.extend(sessions[i])
target = np.array([s[0] for s in session[1:]])
loc_tim = []
loc_tim.extend([(s[0], s[1]) for s in session[:-1]])
loc_np = np.reshape(np.array([s[0] for s in loc_tim]), (len(loc_tim), 1))
tim_np = np.reshape(np.array([s[1] for s in loc_tim]), (len(loc_tim), 1))
trace['loc'] = Variable(torch.LongTensor(loc_np))
trace['tim'] = Variable(torch.LongTensor(tim_np))
trace['target'] = Variable(torch.LongTensor(target))
data_train[u][i] = trace

What does i in data_train[u][i] = trace refer to? Might be some missing indentations?

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.