Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if i != test_fold_index and (val_fold_index is None or i != val_fold_index):
train_val.extend(folds[i])
if val_fold_index is not None:
train = train_val
else:
random.seed(seed)
random.shuffle(train_val)
train_size = int(sizes[0] * len(train_val))
train = train_val[:train_size]
val = train_val[train_size:]
return MoleculeDataset(train), MoleculeDataset(val), MoleculeDataset(test)
elif split_type == 'scaffold':
return scaffold_split(data, sizes=sizes, balanced=False, logger=logger)
elif split_type == 'scaffold_balanced':
return scaffold_split(data, sizes=sizes, balanced=True, seed=seed, logger=logger)
elif split_type == 'scaffold_one':
return scaffold_split_one(data)
elif split_type == 'scaffold_overlap':
assert scaffold_overlap is not None
return scaffold_split_overlap(data, overlap=scaffold_overlap, seed=seed, logger=logger)
elif split_type == 'random':
data.shuffle(seed=seed)
train_size = int(sizes[0] * len(data))
train_val_size = int((sizes[0] + sizes[1]) * len(data))
if val_fold_index is not None:
train = train_val
else:
random.seed(seed)
random.shuffle(train_val)
train_size = int(sizes[0] * len(train_val))
train = train_val[:train_size]
val = train_val[train_size:]
return MoleculeDataset(train), MoleculeDataset(val), MoleculeDataset(test)
elif split_type == 'scaffold':
return scaffold_split(data, sizes=sizes, balanced=False, logger=logger)
elif split_type == 'scaffold_balanced':
return scaffold_split(data, sizes=sizes, balanced=True, seed=seed, logger=logger)
elif split_type == 'scaffold_one':
return scaffold_split_one(data)
elif split_type == 'scaffold_overlap':
assert scaffold_overlap is not None
return scaffold_split_overlap(data, overlap=scaffold_overlap, seed=seed, logger=logger)
elif split_type == 'random':
data.shuffle(seed=seed)
train_size = int(sizes[0] * len(data))
train_val_size = int((sizes[0] + sizes[1]) * len(data))
train = data[:train_size]
val = data[train_size:train_val_size]