flair.data.randomly_split_into_two_datasets#

flair.data.randomly_split_into_two_datasets(dataset, length_of_first, random_seed=None)View on GitHub#

Shuffles and splits a dataset into two Subsets.

Parameters:
  • dataset (Dataset) – Input dataset.

  • length_of_first (int) – Desired number of samples in the first subset.

  • random_seed (Optional[int], optional) – Seed for reproducible shuffle. Defaults to None.

Returns:

The two dataset subsets.

Return type:

tuple[Subset, Subset]

Raises:

ValueError – If length_of_first is invalid.