In trying to create a time-series forecasting model, the main aim is to send data of product id in a singularity. For example, while using Keras.dataloader only data of product id 'mp000000000000005' should be sent and not any other data.
Below is the data I am using:
product_id rpt_date index total_views total_cart_adds total_order_unit total_gmv score
mp000000000000005 2022-07-24 5 0 0 0.0 0.584963
mp000000000000005 2022-07-25 1 0 0 0.0 1.736966
mp000000000000005 2022-07-26 0 0 0 0.0 0.000000
mp000000000001108 2022-07-10 4 0 0 0.0 0.263034
mp000000000001108 2022-07-11 1 0 0 0.0 1.736966
mp000000000001108 2022-07-12 0 0 0 0.0 0.000000
mp000000000000055 2022-07-21 0 0 0 0.0 0.000000
mp000000000000055 2022-07-22 3 0 0 0.0 0.152003
mp000000000000055 2022-07-23 0 0 0 0.0 0.000000
The requirement is that I want to send data of n days of the 1 product id at a time and then do the same for all the other product ids in the dataset.
This is the Code for DataLoader
class DataLoader(Sequence):
def __init__(self,X,y,batch_size=1024):
self.X=X
self.y=y
self.batch_size=batch_size
def __len__(self):
return len(self.y)
def __getitem__(self,index):
#Code is mentioned below
def create_dataset(dataset, look_back=1):
dataX, dataY = [], []
for p in range(len(dataset)-(look_back-1)):
a = dataset[p:(p+look_back), 0]
dataX.append(a)
dataY.append(dataset[p + look_back, 0])
return np.array(dataX), np.array(dataY)
def __len__(self):
return len(self.X)//self.batch_size