Giter Site home page Giter Site logo

bigandsweet / a-comparative-study-of-loss-functions-traffic-predictions-in-regular-and-congestion-scenarios Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xieyangxinyu/a-comparative-study-of-loss-functions-traffic-predictions-in-regular-and-congestion-scenarios

0.0 0.0 0.0 2.18 MB

Source Code for the paper "A Comparative Study of Loss Functions: Traffic Predictions in Regular and Congestion Scenarios"

Python 6.07% Jupyter Notebook 93.93%

a-comparative-study-of-loss-functions-traffic-predictions-in-regular-and-congestion-scenarios's Introduction

A Comparative Study of Loss Functions: Traffic Predictions in Regular and Congestion Scenarios

This repository reproduces the results reported in A Comparative Study of Loss Functions: Traffic Predictions in Regular and Congestion Scenarios.

Requirements

Dependency can be installed using the following command:

pip install -r requirements.txt

Retraining all the models

Under the four folders of the form $MODEL(-quantile) (D2STGNN, D2STGNN-quantile, Graph-WaveNet, Graph-WaveNet-quantile), we provide the adapted source code for each model to reproduce the results in this paper.

  • You can follow the instructions in the README.md under each of these four folders to retrain the models. After training, the best model checkpoints in training will be saved under archive, and the predicted traffic speed in the test set will be saved under result.
  • Quantile loss requires a slightly different model output structure than the other loss functions. -quantile means that the we made changes to the code in order to adapt to the Quantile Loss implemented in Quantifying Uncertainty in Deep Spatiotemporal Forecasting, KDD 2021.
  • All the other loss functions (mae, mse, mae-focal, mse-focal, bmse1, bmse9, huber, kirtosis, Gumbel) are implementeed under $MODEL. For Graph-WaveNet, the loss functions are implemented under util.py; for D2STGNN, the loss functions are implemented under models/losses.py.

Download the METR-LA and PEMS-BAY folders. Both folders contain

  • two subfolders GraphWaveNet and D2STGNN. These two folders contain
    • the best model checkpoints in training, under models folder; and
    • all the predicted traffic speed in the test set in $MODEL-$LOSS.pkl.
    • These can also be generated by retraining the models, as described in the last section.
  • Source data files: METR-LA/metr-la.h5, METR-LA/graph_sensor_locations.csv, PEMS-BAY/pems-bay.h5, PEMS-BAY/graph_sensor_locations_bay.csv.
  • change_points.pkl, change_point_intervals.pkl and congested.pkl. These can also be generated following the instructions below.

Metric Computation

To run our metric computation, we need change_point_intervals.pkl and congested.pkl for the METR-LA and PEMS-BAY datasets.

The change_points.pkl contains all the identified change points in the time series of the historical traffic speed of each of the sensor location. The change_point_intervals.pkl incorporates two-time steps preceding and following each identified change point. To regenerated all the change points in METR-LA and PEMS-BAY datasets, run

python find_change_points.py --path $DATA_PATH

Replace $DATA_PATH by METR-LA or PEMS-BAY. For example, you can run

python find_change_points.py --path METR-LA

Please note that due to the computational cost of offline changepoint identification algorithms, this can take a few hours to run.

The congested.pkl contains all the sensor locations with significant bimodal pattern in the histogram of the historical traffic speed. To regenerate this file for METR-LA and PEMS-BAY datasets, run

python bimodal.py --path $DATA_PATH

Replace $DATA_PATH by METR-LA or PEMS-BAY. For example, you can run

python bimodal.py --path METR-LA

If you would like to visualize all the bimodal distributions, as well as an interactive map as shown in Figure 2 of the paper, you can run bimodal-LA.ipynb or bimodal-bay.ipynb.

Finally, run

python metrics.py --model GraphWaveNet --dataset METR-LA
python metrics.py --model D2STGNN --dataset METR-LA
python metrics.py --model GraphWaveNet --dataset PEMS-BAY
python metrics.py --model D2STGNN --dataset PEMS-BAY

to generate all the tables in the paper.

a-comparative-study-of-loss-functions-traffic-predictions-in-regular-and-congestion-scenarios's People

Contributors

xieyangxinyu 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.