# fiftyone.utils.splits¶

Dataset split utilities.

Functions:

 random_split(sample_collection, split_fracs) Generates a random partition of the samples in the collection according to the specified split fractions.
fiftyone.utils.splits.random_split(sample_collection, split_fracs, seed=None)

Generates a random partition of the samples in the collection according to the specified split fractions.

The partition is denoted by tagging each sample with its assigned split.

Example:

import fiftyone as fo
import fiftyone.utils.splits as fous
import fiftyone.zoo as foz

# A dataset with ground_truth detections and no tags
dataset = (
.select_fields("ground_truth")
.set_field("tags", [])
).clone()

fous.random_split(dataset, {"train": 0.7, "test": 0.2, "val": 0.1})

print(dataset.count_sample_tags())
# {'train': 140, 'test': 40, 'val': 20}

Parameters
• sample_collection – a fiftyone.core.collections.SampleCollection

• split_fracs – a dict mapping split tag strings to split fractions in [0, 1]. The split fractions are normalized so that they sum to 1, if necessary

• seed (None) – an optional random seed