avalanche.benchmarks.split_validation_class_balanced(validation_size: int | float, dataset: TaskAwareSupervisedClassificationDataset) Tuple[TaskAwareSupervisedClassificationDataset, TaskAwareSupervisedClassificationDataset][source]

Class-balanced dataset split.

This splitting strategy splits dataset into train and validation data of size validation_size using a class-balanced split. Samples of each class are chosen randomly.

You can use this split strategy to split a benchmark with:

validation_size = 0.2
foo = lambda data: split_validation_class_balanced(validation_size, data)
bm = benchmark_with_validation_stream(bm, split_strategy=foo)
  • validation_size – The percentage of samples to allocate to the validation experience as a float between 0 and 1.

  • dataset – The dataset to split.


A tuple containing 2 elements: the new training and validation datasets.