question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

data format - from pandas to gluonts data format for both uni-variate and multivariate data

See original GitHub issue

Hi @kashif

I hope your well! I am just trying to get familiar with the library and I generally work with the pandas data format. Could you help me format my data and create a basic uni-variate model for prediction into the future.

import numpy as np

import pandas as pd
import yfinance as yf
data = yf.download("SPY", start="2012-01-01", end="2017-04-30")['Adj Close']
data=pd.DataFrame(data)
data

from gluonts.dataset.common import ListDataset
training_data = ListDataset(
    [{"start": data.index[0], "target": data.values[:1300]}],
    freq = "1D"
)

from gluonts.dataset.common import ListDataset
test_data = ListDataset(
    [{"start": data.index[1301], "target": data.values[1301:1339]}],
    freq = "1D"
)


from gluonts.model.simple_feedforward import SimpleFeedForwardEstimator
from gluonts.mx.trainer import Trainer

estimator = SimpleFeedForwardEstimator(
    num_hidden_dimensions=[10],
    prediction_length=38,
    context_length=100,
    freq='1D',
    trainer=Trainer(ctx="cpu", 
                    epochs=5, 
                    learning_rate=1e-3, 
                    num_batches_per_epoch=100
                   )
)
predictor = estimator.train(training_data=training_data)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12

github_iconTop GitHub Comments

1reaction
kashifcommented, Sep 21, 2020

@andrewcztrack you just make a list of dicts with "target": [1, 4,2, ....] and "start" being the start date and this list you use to instantiate the train_ds = ListDataset(...) So just loop over you pandas dataframe assuming it has multiple time series and for each time series just make the target and start dictonary…

1reaction
andrewcztrackcommented, Sep 21, 2020

Hi @kashif ! my laptop is about to die. can I touch base in a few hours. Kind regards and thanks, Andrew

Read more comments on GitHub >

github_iconTop Results From Across the Web

from pandas to gluonts data format for both uni-variate and ...
I am just trying to get familiar with the library and I generally work with the pandas data format. Could you help me...
Read more >
pandas.DataFrame based dataset - GluonTS documentation
This tutorial covers how to use GluonTS's pandas DataFrame based dataset ... Here, we are given data in the wide format, where time...
Read more >
Timeseries forecasting with gluonts and DeepAR - Kaggle
GluonTS is a Python package for time series forecasting, focusing on deep ... Model + Paper, Local/global, Data layout, Architecture/method, Implementation ...
Read more >
Basic usage of GluonTS for probabilistic, deep learning-based ...
The data are originally in CSV format. ... Unlike traditional univariate forecasting models, recent deep learning-based models are capable ...
Read more >
Guide To GluonTS and PytorchTS For Time-Series Forecasting
#importing gluonTS utilities and pandas from gluonts.dataset import ... prediction = next(predictor.predict(data)) print(prediction.mean) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found