It is often necessary to split datasets into subsets for training, testing, and validation. It is also advisable to shuffle datasets so they are not affected by systematic bias due to the order in which the data was ingested. This functionality is available inside the hub.util module:
from hub import Dataset
from hub.util import shuffle, split
The shuffle() method returns a randomly shuffled version of the original dataset by shuffling the dataset indices.The data is not shuffled in long-term storage.
ds = Dataset('dataset_path')
ds_shuffled = shuffle(ds)
Since the indices are shuffled fully-randomly, data corresponding to adjacent indices are loaded from different chunks, which significantly reduces the data reading speed.
A method for shuffling a dataset by shuffling chunks is coming soon, and it will enable random shuffling without sacrificing data reading speed.
The split method returns a list of datasets that contain a subset of the original datasets according to user-specified proportions