Code Monkey home page Code Monkey logo

deepar-pytorch's Introduction

Original Authors:

Yunkai Zhang([email protected]) - University of California, Santa Barbara

Qiao Jiang - Brown University

Xueying Ma - Columbia University

Acknowledgement: Professor Xifeng Yan's group at UC Santa Barbara. Part of the work was done at WeWork.

https://github.com/zhykoties/TimeSeries

List of Implementations:

Currently, the reimplementation of the DeepAR paper(DeepAR: Probabilistic Forecasting with Autoregressive Recurrent Networks https://arxiv.org/abs/1704.04110) is available in PyTorch. More papers will be coming soon.

Traffic: https://archive.ics.uci.edu/ml/datasets/PEMS-SF

Electricity: https://archive.ics.uci.edu/ml/datasets/ElectricityLoadDiagrams20112014

Parts: https://robjhyndman.com/expsmooth/expsmooth_data.zip

To run:

  1. Install all dependencies listed in requirements.txt. Note that the model has only been tested in the versions shown in the text file.

  2. Download the dataset and preprocess the data:

    python preprocess_elect.py
  3. Start training:

    python train.py
    • If you want to perform ancestral sampling,

      python train.py --sampling
    • If you do not want to do normalization during evaluation,

      python train.py --relative-metrics
  4. Evaluate a set of saved model weights:

    python evaluate.py
  5. Perform hyperparameter search:

     python search_params.py

Results

​ The model is evaluated on the electricity dataset, which contains the electricity consumption of 370 households from 2011 to 2014. Under hourly frequency, we use the first week of September, 2014 as the test set and all time steps prior to that as the train set. Following the experiment design in DeepAR, the window size is chosen to be 192, where the last 24 is the forecasting horizon. History (number of time steps since the beginning of each household), month of the year, day of the week, and hour of the day are used as time covariates. Notice that some households started at different times, so we only use windows that contain non-missing values.

​ Under Gaussian likelihood, we use the Adam optimizer with early stopping to train the model for 20 epoches. The same set of hyperparameters is used as outlined in the paper. Weights with the best ND value is selected, where ND = 0.06349, RMSE = 0.452, rou90 = 0.034 and rou50 = 0.063.

​ Sample results on electricity. The top 10 plots are sampled from the test set with the highest 10% ND values, whereas the bottom 10 plots are sampled from the rest of the test set.

Sample results on electricity. The top 10 plots are sampled from the test set with the highest 10% ND values, whereas the bottom 10 plots are sampled from the rest of the test set.

deepar-pytorch's People

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

deepar-pytorch's Issues

你可以详细说一下数据处理的过程吗

在preprocess_elect.py文件中,你是如何对数据进行处理的吗,数据的label是如何划分的呢?十分感谢
In the preprocess_elect.py file, how do you process the data, and how are the labels of the data divided? Thank you very much

deepar training loss is negative?

Hi, when training the deear program, the train_loss is negative, and the value is train_loss: -1.537808895111084,
It seems something wrong, the loss_fn return -torch.mean(likelood) is that right? loss_fn in below:

def loss_fn(mu: Variable, sigma: Variable, labels: Variable):
'''
Compute using gaussian the log-likehood which needs to be maximized. Ignore time steps where labels are missing.
Args:
mu: (Variable) dimension [batch_size] - estimated mean at time step t
sigma: (Variable) dimension [batch_size] - estimated standard deviation at time step t
labels: (Variable) dimension [batch_size] z_t
Returns:
loss: (Variable) average log-likelihood loss across the batch
'''
zero_index = (labels != 0)
distribution = torch.distributions.normal.Normal(mu[zero_index], sigma[zero_index])
likelihood = distribution.log_prob(labels[zero_index])
return -torch.mean(likelihood)

thx,

james

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.