modularml.core.splitters.random_splitter

Classes

RandomSplitter(ratios[, seed])

Creates a random splitter based on sample ratios

class modularml.core.splitters.random_splitter.RandomSplitter(ratios: Dict[str, float], seed: int = 42)

Bases: BaseSplitter

Creates a random splitter based on sample ratios

Parameters:
  • ratios (Dict[str, float]) – Keyword-arguments that define subset names and percent splits. E.g., RandomSplitter(train=0.5, test=0.5). All values must add to exactly 1.0.

  • seed (int) – The seed of the random generator.

__init__(ratios: Dict[str, float], seed: int = 42)

Creates a random splitter based on sample ratios

Parameters:
  • ratios (Dict[str, float]) – Keyword-arguments that define subset names and percent splits. E.g., RandomSplitter(train=0.5, test=0.5). All values must add to exactly 1.0.

  • seed (int) – The seed of the random generator.

split(samples: List[Sample]) Dict[str, List[str]]

Randomly splits a list of samples based on the defined ratios.

Parameters:

samples (List[Sample]) – The list of samples to split.

Returns:

Dictionary mapping subset names to Sample.uuid.

Return type:

Dict[str, List[str]]