Hello folks,
I am trying to build a model to get buy and sell prediction on time series. I’ve generated my data and put it in separated folders:
- train
- buy
- sell
- valid
- buy
- sell
To parse the data to use with fastai i’ve written a custom collate function to generate the databunch. Here is the custom function:
def collate(samples:BatchSamples):
input_tensor = []
labels = torch.zeros(len(samples),1,dtype=torch.long)
for i,s in enumerate(samples):
matrix = pd.read_pickle(s[0]).values
matrix = np.stack((matrix,)*3, axis=0).astype('float32')
input_tensor.append(matrix)
labels[i] = 0 if (str(s[1]) == "buy") else 1
return tensor(input_tensor), tensor(labels)
My call to construct the data bunch object:
data = (ItemList.from_folder(matrix_path)
.split_by_folder()
.label_from_folder()
.databunch(bs=128, collate_fn=collate))
The problem is when I call fit_one_cycle all predictions are 0(buy). Here is the confusion matrix:
Can anyone shed some light where the error is?