train_val_test_split#

openstef_models.utils.data_split.train_val_test_split(dataset: T, split_func: Callable[[T, float], tuple[T, T]], val_fraction: float, test_fraction: float) tuple[T, T, T][source]#

Split a dataset into train, validation, and test sets chronologically.

Divides the dataset into training, validation, and testing sets based on temporal order, ensuring that all training data comes before all validation data, which comes before all testing data.

The split points are determined by the val_fraction and test_fraction parameters.

Parameters:
  • dataset (TypeVar(T)) – The dataset to split.

  • split_func (Callable[[TypeVar(T), float], tuple[TypeVar(T), TypeVar(T)]]) – Function to use for splitting the dataset into two parts.

  • val_fraction (float) – Fraction of data to include in the validation split.

  • test_fraction (float) – Fraction of data to include in the test split.

  • dataset

  • split_func

  • val_fraction

  • test_fraction

Returns:

Tuple of (train_dataset, val_dataset, test_dataset).

Raises:

ValueError – If test_fraction + val_fraction is not less than 1.0.

Return type:

tuple[TypeVar(T), TypeVar(T), TypeVar(T)]