googlebot:

Is your Timeline_Dataset randomly selecting time moments on every iteration? If not, your network will only see and predict fifth minute exits.


I’m only randomly selecting parts of timeline, if it’s above the size of the set lookback interval.
So with a lookback of 4, every timeline that is shorter then 4 timesteps, should not be affected. But all the timeslines that are longer, should be sliced at some random place.
Here is the dataset code, for reference. I’m loading from two different files, that are both from the same time period.
The file terminator_data contains all users, who have terminated their session on the website.
And the other file contains data from users who have not done so.
With a ratio of 1 termination timeline for every 43 non termination timelines.
class Timeline_Dataset(Dataset):

    def __init__(self, root, lookback, transform=None):

        self.root = root
        self.lookback = lookback
        self.transform = transform
        self.data = []
        self.__preprocess_to_list__()

        
    def __len__(self):
        return len(self.data)


    def __getitem__(self, idx):
        sample = self.data[idx]
        
        if self.lookback > len(sample):
            sample = [sample[0][-self.lookback:], sample[1][-self.lookback:]]
        else:
            rnd = randrange(0, len(sample), 1)
            sample = [sample[0][:rnd][-self.lookback:], sample[1][-self.lookback:]]


        if self.transform:
            sample = self.transform(sample)
            
        return sample
    
            
    def __preprocess_to_list__(self):
        files = ['terminator_data','user_data']
        for part in files:
            csv_file = self.root + part + '_processed.csv'
            print('Loading ' + part + ' dataset...')
            df = pd.read_csv(csv_file, sep=',',
                    index_col = 0,
                    engine='python',
                    error_bad_lines=False)
            user_list = split_data_by_customer(df)
            
            for x in user_list:
                label = x[['Target_0.0', 'Target_1.0']]
                x.drop(['USER_ID','Target_0.0', 'Target_1.0'], axis=1, inplace = True)
            
                x = torch.tensor(x[x.columns].values)
                y = torch.tensor(label[label.columns].values)
                
                self.data.append([x,y])
            print('Preprocessing complete.')
            print('Loaded ' + str(self.__len__()) + ' datapoints.')


class PadSequences:
    def __call__(self, batch):
        # Each element in "batch" is a tuple (data, label).
        # Sort the batch in the descending order
        sorted_batch = sorted(batch, key=lambda x: x[0].shape[0], reverse=True)
        # Get each sequence and pad it
        sequences = [x[0] for x in sorted_batch]
        sequences_padded = torch.nn.utils.rnn.pad_sequence(sequences, batch_first=True)
        # Also need to store the length of each sequence
        # This is later needed in order to unpad the sequences
        lengths = torch.LongTensor([len(x) for x in sequences])
        # Don't forget to grab the labels of the *sorted* batch
        labels = [x[1] for x in sorted_batch]
        labels_padded = torch.nn.utils.rnn.pad_sequence(labels, batch_first=True)
        return sequences_padded, lengths, labels_padded