I am working on pytorch code of time series forecasting using TFT method. Here
- First I have taken a csv file to read my data that has 4 columns with numeric values. (stock prices)
- I converted the data into TimeSeriesDataSet() format.
- Then converted the datasets to dataloaders for training val, and testing using to_dataloader() method.
- I am trying to extract the feature (x) and label (y) using below sample code
for x, y in iter(val_dataloader)
Here y represent the target column for which I want my model to make predictions. I have options to make declare single and multiple target columns like this
a: target_colum = “colum1”
b: target_colum = [‘colum1’, colum2’] etc.
in case of “a” where I have only one column to predict I can extract the actual labels
like this
#actuals = torch.cat([y[0] for x, y in iter(test_dataloader)])
However in case of “b” where I have multiple columns I am not able to extract the actual labels
when I explored I found that “y” is a tuple and in my case there are two target columns then in the “y” data is stored like this
horizon = n
print(y) = ( [ tensor( [ [1], [2],…[n no. of predictions for column 1] ] ) , tensor( [ [1], [2],…[n no. of predictions for column 2] ] ) ] , none)
and if there are multiple test data like if n = 30 and I have 120 rows in the test data then this list continues with 4 such data.
my problem is I want to extract this data from “y”. Kindly help I am trapped in these square and small brackets. My intention is to store all the values in a numpy array with size (n, 2) .