awslabs / gluonts

Probabilistic time series modeling in Python
https://ts.gluon.ai
Apache License 2.0
4.55k stars 747 forks source link

Weekly prediction - from daily data #530

Closed kaleming closed 4 years ago

kaleming commented 4 years ago

Hi,

Supposing I have a daily timeseries of many products and I want to make a weekly prediction

{'start': Timestamp('2019-04-01 00:00:00', freq='D'), 'target': array([ 0., 10., 2., 2., 21., 6., 5., 3., 5., 4., 10., 8., 1., 1., 1., 1., 0., 2., 0.], dtype=float32), 'feat_static_cat': array([ 1, 904]), 'source': SourceContext(source='list_data', row=2)}

Can I achieve this just changing this argument:

estimator = deepar.DeepAREstimator(freq='W')

And still keeping a daily train dataset ? Or I must resample all my daily dataset before ?

mbohlkeschneider commented 4 years ago

Hi @kaleming,

you would have to resample the data before passing to GluonTS - GluonTS will not do the resampling for you. Changing the frequency in the estimator will just change the features/lags that are used in the model but will do nothing to the data itself.

kaleming commented 4 years ago

Thanks @mbohlkeschneider.

Just one more question:

My daily start day is '2019-04-01':

`{'start': Timestamp('2019-04-01 00:00:00', freq='D')

If I resample to weekly it will change to the closest sunday ('2019-04-06').

Does it make difference to keep the 'start' argument on 2019-04-01 (Tuesday) instead of sunday ('2019-04-06') ? Will Gluonts understand that it starts on the same week ?

mbohlkeschneider commented 4 years ago

The start field should contain the data in which the target time series starts. So if the resampled data starts on the Sunday, the field should also start on the Sunday.

kaleming commented 4 years ago

Ok.

Thank you again.