Home

Awesome

EasyTPP [ICLR 2024]

<div align="center"> <a href="PyVersion"> <img alt="Python Version" src="https://img.shields.io/badge/python-3.9+-blue.svg"> </a> <a href="LICENSE-CODE"> <img alt="Code License" src="https://img.shields.io/badge/license-Apache-000000.svg?&color=f5de53"> </a> <a href="commit"> <img alt="Last Commit" src="https://img.shields.io/github/last-commit/ant-research/EasyTemporalPointProcess"> </a> </div> <div align="center"> <a href="https://pypi.python.org/pypi/easy-tpp/"> <img alt="PyPI version" src="https://img.shields.io/pypi/v/easy-tpp.svg?style=flat-square&color=b7534" /> </a> <a href="https://static.pepy.tech/personalized-badge/easy-tpp"> <img alt="Downloads" src="https://static.pepy.tech/personalized-badge/easy-tpp?period=total&units=international_system&left_color=black&right_color=blue&left_text=Downloads" /> </a> <a href="https://huggingface.co/easytpp" target="_blank"> <img alt="Hugging Face" src="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-EasyTPP-ffc107?color=ffc107&logoColor=white" /> </a> <a href="https://github.com/ant-research/EasyTemporalPointProcess/issues"> <img alt="Open Issues" src="https://img.shields.io/github/issues-raw/ant-research/EasyTemporalPointProcess" /> </a> </div>

EasyTPP is an easy-to-use development and application toolkit for Temporal Point Process (TPP), with key features in configurability, compatibility and reproducibility. We hope this project could benefit both researchers and practitioners with the goal of easily customized development and open benchmarking in TPP. <span id='top'/>

| <a href='#features'>Features</a> | <a href='#model-list'>Model List</a> | <a href='#dataset'>Dataset</a> | <a href='#quick-start'>Quick Start</a> | <a href='#benchmark'>Benchmark</a> |<a href='#doc'>Documentation</a> |<a href='#todo'>Todo List</a> | <a href='#citation'>Citation</a> |<a href='#acknowledgment'>Acknowledgement</a> | <a href='#star-history'>Star History</a> |

News

<span id='news'/> <details> <summary>Click to see previous news</summary> <p> - [09-02-2023] We published two non-anthropogenic datasets [earthquake](https://drive.google.com/drive/folders/1ubeIz_CCNjHyuu6-XXD0T-gdOLm12rf4) and [volcano eruption](https://drive.google.com/drive/folders/1KSWbNi8LUwC-dxz1T5sOnd9zwAot95Tp?usp=drive_link)! See <a href='#dataset'>Dataset</a> for details. - [05-29-2023] We released ``EasyTPP`` v0.0.1! - [12-27-2022] Our paper [Bellman Meets Hawkes: Model-Based Reinforcement Learning via Temporal Point Processes](https://arxiv.org/abs/2201.12569) was accepted by AAAI'2023! - [10-01-2022] Our paper [HYPRO: A Hybridly Normalized Probabilistic Model for Long-Horizon Prediction of Event Sequences](https://arxiv.org/abs/2210.01753) was accepted by NeurIPS'2022! - [05-01-2022] We started to develop `EasyTPP`.</p> </details>

Features <a href='#top'>[Back to Top]</a>

<span id='features'/>

Model List <a href='#top'>[Back to Top]</a>

<span id='model-list'/>

We provide reference implementations of various state-of-the-art TPP papers:

NoPublicationModelPaperImplementation
1KDD'16RMTPPRecurrent Marked Temporal Point Processes: Embedding Event History to VectorTensorflow<br/>Torch
2NeurIPS'17NHPThe Neural Hawkes Process: A Neurally Self-Modulating Multivariate Point ProcessTensorflow<br/>Torch
3NeurIPS'19FullyNNFully Neural Network based Model for General Temporal Point ProcessesTensorflow<br/>Torch
4ICML'20SAHPSelf-Attentive Hawkes processTensorflow<br/>Torch
5ICML'20THPTransformer Hawkes processTensorflow<br/>Torch
6ICLR'20IntensityFreeIntensity-Free Learning of Temporal Point ProcessesTensorflow<br/>Torch
7ICLR'21ODETPPNeural Spatio-Temporal Point Processes (simplified)Tensorflow<br/>Torch
8ICLR'22AttNHPTransformer Embeddings of Irregularly Spaced Events and Their ParticipantsTensorflow<br/>Torch

Dataset <a href='#top'>[Back to Top]</a>

<span id='dataset'/>

We preprocessed one synthetic and five real world datasets from widely-cited works that contain diverse characteristics in terms of their application domains and temporal statistics:

Per users' request, we processed two non-anthropogenic datasets

Quick Start <a href='#top'>[Back to Top]</a>

<span id='quick-start'/>

Colab Tutorials

Explore the following tutorials that can be opened directly in Google Colab:

End-to-end Example

We provide an end-to-end example for users to run a standard TPP model with EasyTPP.

Step 1. Installation

First of all, we can install the package either by using pip or from the source code on Github.

To install the latest stable version:

pip install easy-tpp

To install the latest on GitHub:

git clone https://github.com/ant-research/EasyTemporalPointProcess.git
cd EasyTemporalPointProcess
python setup.py install

Step 2. Prepare datasets

We need to put the datasets in a local directory before running a model and the datasets should follow a certain format. See OnlineDoc - Datasets for more details.

Suppose we use the taxi dataset in the example.

Step 3. Train the model

Before start training, we need to set up the config file for the pipeline. We provide a preset config file in Example Config. The details of the configuration can be found in OnlineDoc - Training Pipeline.

After the setup of data and config, the directory structure is as follows:


    data
     |______taxi
             |____ train.pkl
             |____ dev.pkl
             |____ test.pkl

    configs
     |______experiment_config.yaml

Then we start the training by simply running the script


import argparse
from easy_tpp.config_factory import Config
from easy_tpp.runner import Runner


def main():
    parser = argparse.ArgumentParser()

    parser.add_argument('--config_dir', type=str, required=False, default='configs/experiment_config.yaml',
                        help='Dir of configuration yaml to train and evaluate the model.')

    parser.add_argument('--experiment_id', type=str, required=False, default='NHP_train',
                        help='Experiment id in the config file.')

    args = parser.parse_args()

    config = Config.build_from_yaml_file(args.config_dir, experiment_id=args.experiment_id)

    model_runner = Runner.build_from_config(config)

    model_runner.run()


if __name__ == '__main__':
    main()

A more detailed example can be found at OnlineDoc - QuickStart.

Documentation <a href='#top'>[Back to Top]</a>

<span id='doc'/>

The classes and methods of EasyTPP have been well documented so that users can generate the documentation by:

cd doc
pip install -r requirements.txt
make html

NOTE:

The full documentation is available on the website.

Benchmark <a href='#top'>[Back to Top]</a>

<span id='benchmark'/>

In the examples folder, we provide a script to benchmark the TPPs, with Taxi dataset as the input.

To run the script, one should download the Taxi data following the above instructions. The config file is readily setup up. Then run

cd examples
python benchmark_script.py

License <a href='#top'>[Back to Top]</a>

This project is licensed under the Apache License (Version 2.0). This toolkit also contains some code modified from other repos under other open-source licenses. See the NOTICE file for more information.

Todo List <a href='#top'>[Back to Top]</a>

<span id='todo'/>

Citation <a href='#top'>[Back to Top]</a>

<span id='citation'/>

If you find EasyTPP useful for your research or development, please cite the following <a href="https://arxiv.org/abs/2307.08097" target="_blank">paper</a>:

@inproceedings{xue2024easytpp,
      title={EasyTPP: Towards Open Benchmarking Temporal Point Processes}, 
      author={Siqiao Xue and Xiaoming Shi and Zhixuan Chu and Yan Wang and Hongyan Hao and Fan Zhou and Caigao Jiang and Chen Pan and James Y. Zhang and Qingsong Wen and Jun Zhou and Hongyuan Mei},
      booktitle = {International Conference on Learning Representations (ICLR)},
      year = {2024},
      url ={https://arxiv.org/abs/2307.08097}
}

Acknowledgment <a href='#top'>[Back to Top]</a>

<span id='acknowledgment'/>

The project is jointly initiated by Machine Intelligence Group, Alipay and DAMO Academy, Alibaba.

The following repositories are used in EasyTPP, either in close to original form or as an inspiration:

Star History <a href='#top'>[Back to Top]</a>

<span id='star-history'/>

Star History Chart