Search code examples
time-seriespytorch-forecasting

Shuffling of time series data in pytorch-forecasting


I am using pytorch-forecasting for count time series. I have some date information such as hour of day, day of week, day of month etc...

when I assign these as categorical variables in TimeSeriesDataSet using time_varying_known_categoricals the training.data['categoricals'] values seem shuffled and not in the right order as the target. Why is that?

pandas dataframe is like below before going through TimeSeriesDataSet

enter image description here

After the following code

enter image description here

why has hour of day column changed to 0, 1, 12, 17?


Solution

  • Actually, the time_varying_known_categoricals are NOT shuffled. The categories assigned to them are not in order like 1 for 1st hour, 2 for 2nd hour etc.. that's why it feels like it has shuffled the time series. I tried to align "hour_of_day" categorical variable for 3 days. I noticed that the encoding for each hour matches correcly for each day so there is no shuffling. This information should be mentioned in the doc string atleast. It will save a lot of time and confusion.

    enter image description here