commonpower.data_forecasting.nn_forecasting.data_splitting.DatePeriodFractionalSplit
- class DatePeriodFractionalSplit(split_type: DataSplitType, data_source: DataSource, model: NNModule, period_length: timedelta = datetime.timedelta(days=28), train_fraction: float = 0.7, val_fraction: float = 0.15)[source]
Bases:
DatasetSplitThis Splitter first divides the dataset into periods of length period_length in order of the data source. Each period is then split into training, validation, and test sets according to the fractions provided. The advantage over the SimpleFractionalSplit is that we avoid bias based on seasonality or distribution shift over time.
- Parameters:
split_type (DataSplitType) – The type of data splitting.
data_source (DataSource) – The data source.
model (NNModule) – The neural network model.
period_length (timedelta, optional) – The length of each period. Defaults to timedelta(weeks=4).
train_fraction (float, optional) – The fraction of the data to use for training. Defaults to 0.7.
val_fraction (float, optional) – The fraction of the data to use for validation. Defaults to 0.15.
- Returns:
DatasetSplit – The initialized DatasetSplit object.
Methods
Adjusts the index to the correct position in the dataset.