Git Product home page Git Product logo

calendargnn's Introduction

Calendar Graph Neural Networks for Modeling Time Structures in Spatiotemporal User Behaviors

Description: This repository contains the reference implementation of CalendarGNN model proposed in the paper Calendar Graph Neural Networks for Modeling Time Structures in Spatiotemporal User Behaviors accepted by KDD20.

Model

The architecture of CalendarGNN The architecture of CalendarGNN incorporates two networked structures. One is a tripartite network of items, sessions, and locations. The other is a hierarchical calendar network of hour, week, and weekday nodes. It first aggregates embeddings of location and items into session embeddings via the tripartite network, and then generates user embeddings from the session embeddings via the calendar structure. The user embeddings preserve spatial patterns and temporal patterns of a variety of periodicity (e.g., hourly, weekly, and weekday patterns). It adopts the attention mechanism to model complex interactions among the multiple patterns in user behaviors.

Usage

1. Dependencies

This code package was developed and tested with Python 3.7 and PyTorch 1.2.0. Make sure all dependencies specified in the ./requirements.txt file are satisfied before running the model. This can be achieved by

pip install -r requirements.txt

Other environment management tool such as Conda can also be used.

2. Data

Note: Due to privacy constraints, this repository currently does not contain the datasets of spatiotemporal user behaviors described in the paper. We are working on necessary anonymization procedures and will update this section once available.

In the meantime, any other datasets of spatiotemporal user behaviors can be placed into the ./data/ folder. Predefined paths for locating necessary data files can be found in the ./config.py file.

3. Run

To train the model, run

python main.py --model calendargnn --label gender --num_epochs 10

List of arguments:

  • --model: The model to use. Valid choices include calendargnn and calendargnnattn. Default is calendargnn
  • --label: The user label for prediction. Valid choices include gender, income and age. Default is gender
  • --num_epochs: Num of epochs for training. Default is 10
  • --rand_seed: Random seed. Default is 999
  • --hidden_dim: Dimension of spatial/temporal unit embeddings. Default is 256
  • --pattern_dim: Dimension of spatial/temporal patterns. Default is 128
  • --best_model_file: Checkpoint file for storing the best model during training. Default is ./best_model.pt
  • --cuda: Use GPU for training the model

During training, the script keeps writing to the checkpoint file specified by the --best_model_file argument. And, it should be explictly given when running batch jobs to avoid lossing training progress. We highly recommend adding --cuda argument for training if possible.

Examples

Other examples are provided in the ./demo.sh file.

Miscellaneous

If you find this code pacakage is helpful, please consider cite us:

@inproceedings{wang2020calendar,
  title={Calendar Graph Neural Networks for Modeling Time Structures in Spatiotemporal User Behaviors},
  author={Wang, Daheng and Jiang, Meng and Syed, Munira and Conway, Oliver and Juneja, Vishal and Subramanian, Sriram and Chawla, Nitesh V},
  booktitle={Proceedings of the 26th ACM SIGKDD International Conference on Knowledge Discovery \& Data Mining},
  pages={2581--2589},
  year={2020}
}

calendargnn's People

Contributors

dahengwang0705 avatar

Watchers

James Cloos avatar

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.