avalanche.benchmarks.split_validation_random
- avalanche.benchmarks.split_validation_random(validation_size: int | float, shuffle: bool, seed: int | None = None, dataset: AvalancheDataset | None = None) Tuple[AvalancheDataset, AvalancheDataset] [source]
Splits an AvalancheDataset in two splits.
The default splitting strategy used by
benchmark_with_validation_stream()
.This splitting strategy simply splits the datasets in two (e.g. a train and validation split) of size validation_size.
When taking inspiration for your custom splitting strategy, please consider that all parameters preceding experience are filled by
benchmark_with_validation_stream()
by using partial from the functools standard library. A custom splitting strategy must have only a single parameter: the experience. Consider wrapping your custom splitting strategy with partial if more parameters are needed.You can use this split strategy with methdos that require a custom split strategy such as :func:`benchmark_with_validation_stream`to split a benchmark with:
validation_size = 0.2 foo = lambda exp: split_validation_class_balanced(validation_size, exp) bm = benchmark_with_validation_stream(bm, split_strategy=foo)
- Parameters:
validation_size – The number of instances to allocate to the
validation experience. Can be an int value or a float between 0 and 1. :param shuffle: If True, instances will be shuffled before splitting.
Otherwise, the first instances will be allocated to the training dataset by leaving the last ones to the validation dataset.
- Parameters:
dataset – The dataset to split.
- Returns:
A tuple containing 2 elements: the new training and validation datasets.