MCPcopy Index your code
hub / github.com/chaoshangcs/GTS

github.com/chaoshangcs/GTS @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
123 symbols 280 edges 17 files 26 documented · 21%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Discrete Graph Structure Learning for Forecasting Multiple Time Series

This is a PyTorch implementation of the paper "Discrete Graph Structure Learning for Forecasting Multiple Time Series", ICLR 2021.

Installation

Install the dependency using the following command:

pip install -r requirements.txt
  • torch
  • scipy>=0.19.0
  • numpy>=1.12.1
  • pandas>=0.19.2
  • pyyaml
  • statsmodels
  • tensorflow>=1.3.0
  • tables
  • future

Data Preparation

The traffic data files for Los Angeles (METR-LA) and the Bay Area (PEMS-BAY) are put into the data/ folder. They are provided by DCRNN.

Run the following commands to generate train/test/val dataset at data/{METR-LA,PEMS-BAY}/{train,val,test}.npz.

# Unzip the datasets
unzip data/metr-la.h5.zip -d data/
unzip data/pems-bay.h5.zip -d data/

# Create data directories
mkdir -p data/{METR-LA,PEMS-BAY}

# METR-LA
python -m scripts.generate_training_data --output_dir=data/METR-LA --traffic_df_filename=data/metr-la.h5

# PEMS-BAY
python -m scripts.generate_training_data --output_dir=data/PEMS-BAY --traffic_df_filename=data/pems-bay.h5

Train Model

When you train the model, you can run:

# Use METR-LA dataset
python train.py --config_filename=data/model/para_la.yaml --temperature=0.5

# Use PEMS-BAY dataset
python train.py --config_filename=data/model/para_bay.yaml --temperature=0.5

Hyperparameters can be modified in the para_la.yaml and para_bay.yaml files.

Design your own model

You can directly modify the model in the "model/pytorch/model.py" file.

Citation

If you use this repository, e.g., the code and the datasets, in your research, please cite the following paper:

@article{shang2021discrete,
  title={Discrete Graph Structure Learning for Forecasting Multiple Time Series},
  author={Shang, Chao and Chen, Jie and Bi, Jinbo},
  journal={arXiv preprint arXiv:2101.06861},
  year={2021}
}

Acknowledgments

DCRNN-PyTorch, GCN, NRI and LDS-GNN.

Core symbols most depended-on inside this repo

inverse_transform
called by 13
lib/utils.py
masked_mape_loss
called by 8
model/pytorch/loss.py
masked_mse_loss
called by 8
model/pytorch/loss.py
masked_mae_loss
called by 7
model/pytorch/loss.py
transform
called by 5
lib/utils.py
masked_rmse_np
called by 4
lib/metrics.py
masked_mae_np
called by 4
lib/metrics.py
masked_mape_np
called by 4
lib/metrics.py

Shape

Method 64
Function 47
Class 12

Languages

Python100%

Modules by API surface

model/pytorch/model.py20 symbols
lib/utils.py19 symbols
lib/metrics_test.py17 symbols
model/pytorch/supervisor.py13 symbols
model/pytorch/cell.py12 symbols
lib/metrics.py12 symbols
lib/AMSGrad.py11 symbols
scripts/eval_baseline_methods.py7 symbols
model/pytorch/loss.py4 symbols
scripts/generate_visualization_data.py3 symbols
scripts/generate_training_data.py3 symbols
train.py1 symbols

For agents

$ claude mcp add GTS \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact