jdb78 / pytorch-forecasting

Time series forecasting with PyTorch
https://pytorch-forecasting.readthedocs.io/
MIT License
3.87k stars 611 forks source link

How to assign prediction to timeseries in NBeats? #527

Closed DonBeo closed 3 years ago

DonBeo commented 3 years ago

Hi, thanks for the great library. I have an usability question.

I have trained an NBeats model on a dataframe containing 16 time series as in the example (https://pytorch-forecasting.readthedocs.io/en/latest/tutorials/ar.html)

Now I am predicting new data from a dataframe as:

pr, x_pr, idx = best_model.predict(data_ts, mode="prediction", return_x=True, return_index=True)

as expected I get prediction for 16 time series and 192 points (this was my prediction length)

pr.shape #= torch.Size([16, 192])

Now how do I assign each row in the prediction to the correct time series? In other words I would like to know to which of my 16 time series each row refers to. In my data the time series is identified by the series column as in the attached figure

image

jdb78 commented 3 years ago

You can use idx here to match them to the timeseries.

DonBeo commented 3 years ago

thanks for answering. So each row of the idx dataframe returned by the function corresponds to a row of pr

I really suggest to add it to the doc as it was not very clear.

Thanks for the work you are doing!!

jdb78 commented 3 years ago

Adding in the latest PR.